-
Notifications
You must be signed in to change notification settings - Fork 16
/
webpack.config.js
43 lines (34 loc) · 1.05 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
const webpack = require('webpack');
const { env } = require('process');
const isProd = env.NODE_ENV === 'production';
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const isNonNil = x => x != null;
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const isProfile = env.PROFILE == 'true';
const envVars = ['NODE_ENV', 'PC_URL', 'FACTOID_URL'];
let conf = {
entry: './src/client/index.js',
output: {
filename: './build/bundle.js'
},
devtool: 'inline-source-map',
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }
]
},
plugins: [
isProfile ? new BundleAnalyzerPlugin() : null,
new webpack.EnvironmentPlugin(envVars),
new webpack.optimize.CommonsChunkPlugin({
name: 'deps',
filename: './build/deps.js',
minChunks( module ){
let context = module.context || '';
return context.indexOf('node_modules') >= 0;
}
}),
isProd ? new UglifyJSPlugin() : null
].filter( isNonNil )
};
module.exports = conf;