-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
62 lines (55 loc) · 1.71 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const rxjsMapping = require('rxjs/_esm5/path-mapping');
module.exports = (env = {}) => ({
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].[chunkhash].js'
},
resolve: {
// RxJS v5 needs a custom opt-in to be resolved as ESM
alias: rxjsMapping(path.resolve(__dirname, 'node_modules'))
},
module: {
rules: [
{ test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
// don't transpile modules == app code as ES modules
presets: [['env', {modules: false}]]
}
}
}
]
},
plugins: [
new webpack.HashedModuleIdsPlugin(),
// creates fewer webpack modules -> improves dead code elimination
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.optimize.UglifyJsPlugin(
env.debugProduction ? {
mangle: false,
compress: {sequences: false, warnings: false, pure_getters: true, passes: 3},
output: {comments: 'all', beautify: true},
sourceMap: true
} : {
mangle: true,
compress: {warnings: false, pure_getters: true, passes: 3},
output: {comments: false},
sourceMap: true
}),
new HtmlWebpackPlugin({template: './src/index.html'}),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
reportFilename: 'wba-report.html'
})
],
devtool: 'source-map',
node: false
});