-
Notifications
You must be signed in to change notification settings - Fork 40
/
webpack.config.js
47 lines (43 loc) · 1.29 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
const path = require('path');
const webpack = require('webpack');
const config = require('./gulp.config.js')();
const alias = require('./webpack-config/alias');
const rules = require('./webpack-config/rules');
const SRC_DIR = path.resolve(__dirname, `./${config.paths.scripts.src}`);
const DIST_DIR = path.resolve(__dirname, `./${config.paths.scripts.dist}`);
const ENV = process.env.npm_lifecycle_event;
const isProd = ENV && ENV.startsWith('build');
module.exports = {
entry: path.resolve(__dirname, config.paths.scripts.entry),
output: {
path: DIST_DIR,
filename: '[name].js',
publicPath: `/${config.paths.dist}`,
},
module: {
rules,
},
context: SRC_DIR,
resolve: {
extensions: ['.js', '.json'],
alias,
modules: ['node_modules'],
},
devtool: '#eval-source-map',
mode: isProd ? 'production' : 'development',
};
if (isProd) {
module.exports.devtool = '#source-map';
module.exports.watch = false;
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false,
},
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
}),
]);
}