forked from PathwayCommons/app-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
41 lines (33 loc) · 1 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
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';
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(['NODE_ENV']),
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;