-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
61 lines (56 loc) · 1.38 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
const path = require('path');
const webpack = require('webpack');
// const bundleAnalyzerPlugin = require('webpack-bundle-analyzer');
const production = process.env.NODE_ENV === 'production';
// Use it to upgrade to the new Webpack
process.traceDeprecation = true;
const config = {
context: path.resolve(__dirname, 'src'),
entry: {
main: ['./scripts/main.js'],
},
target: ['web', 'es5'], // Remove es5 to output es6
performance: {
hints: 'warning', // false, 'error'
},
mode: production === true ? 'production' : 'development',
devtool: production === true ? false : 'eval-cheap-source-map', // 'source-map'
watch: false,
output: {
path: path.resolve(__dirname, './src/scripts'),
filename: '[name].min.js',
},
resolve: {
modules: [path.resolve(__dirname, 'src'), 'node_modules'],
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
},
},
},
],
},
plugins: [
new webpack.DefinePlugin({
DEBUG: JSON.stringify(production !== true),
}),
// new bundleAnalyzerPlugin.BundleAnalyzerPlugin(),
],
};
if (production === true) {
config.optimization = {
minimize: true,
splitChunks: {
chunks: 'all',
name: 'vendor',
},
};
}
module.exports = config;