This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
88 lines (82 loc) · 1.87 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
79
80
81
82
83
84
85
86
87
88
const webpack = require('webpack');
const path = require('path');
const AssetsPlugin = require('assets-webpack-plugin');
const isDev = (process.env.NODE_ENV === 'development');
// plugin that stores the chunkhash on a json file
const assetsPluginInstance = new AssetsPlugin({
filename: 'assets.json',
path: path.join(__dirname, (isDev
? 'lib'
: '.dist'), 'server')
});
// plugins per environment
const plugins = [assetsPluginInstance];
if (!isDev) {
plugins.push(new webpack.LoaderOptionsPlugin({minimize: true, debug: false}));
plugins.push(new webpack.optimize.UglifyJsPlugin({
beautify: false,
mangle: {
screw_ie8: true,
keep_fnames: true
},
compress: {
screw_ie8: true
},
comments: false
}));
}
// babel trnaspile config
const babelConfig = {
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader?cacheDirectory=true',
options: {
presets: [
'es2017',
'stage-0',
[
'env', {
targets: [
{
name: 'ie',
version: '>=10'
}, {
name: 'edge',
version: '>=12'
}, {
name: 'firefox',
version: '>=45'
}, {
name: 'chrome',
version: '>=45'
}, {
name: 'safari',
version: '>=7'
}
]
}
]
]
}
}
};
// webpack config
module.exports = {
target: 'web',
entry: {
main: [
'babel-polyfill', './lib/client/js/main.js'
],
index: ['./lib/client/js/index.js']
},
output: {
path: path.join(__dirname, '.dist/client/js'),
filename: '[name].[chunkhash].bundle.js'
},
devtool: 'cheap-eval-source-map',
module: {
rules: [babelConfig]
},
plugins
};