This repository has been archived by the owner on Mar 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
78 lines (68 loc) · 2.14 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const path = require('path');
const webpack = require('webpack');
const projectConfig = require('./config');
const config = {
externals: [
'vocab',
'wrapper',
'bump-3',
],
resolve: {
alias: {
jquery: `${__dirname}/node_modules/jquery/dist/jquery.min`,
template_engine: `${__dirname}/node_modules/template_engine/template_engine`,
ShareTools: `${__dirname}/node_modules/@bbc/news-vj-sharetools/bin/sharetools.min`,
ShareToolsTemplateForSport: `${__dirname}/node_modules/@bbc/news-vj-sharetools/bin/templates/buttons/template`,
},
modules: [
`${__dirname}source/js`,
path.join(__dirname, 'node_modules'),
path.join(__dirname, 'node_modules/@bbc'),
],
extensions: ['.js'],
},
resolveLoader: {
modules: [path.join(__dirname, 'node_modules')],
},
entry: {
app: [`${__dirname}/source/js/app.js`],
},
module: {
rules: [
{
test: /\.js$/,
exclude: [
/bower_components/,
/node_modules\/(?!(@bbc\/news-vj)).*/, // exclude all node modules except Visual Journalism ones
],
use: {
loader: 'babel-loader',
options: {
presets: [
['es2015', {
loose: true,
}],
],
},
},
},
],
},
// only seems to work when running `webpack` directly
stats: {
colors: true,
},
// required when `debug` is `false - not sure why ("so the wrappers can add plugins"?)
plugins: [],
output: {
library: 'app',
libraryTarget: 'amd',
path: `${process.cwd()}/${projectConfig.outputPath}/assets/`,
filename: 'main.js',
},
};
if (projectConfig.debug === 'false') {
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
config.plugins.push(new UglifyJSPlugin());
}
module.exports = config;