-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
54 lines (50 loc) · 1.11 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
const path = require('path')
const TerserPlugin = require('terser-webpack-plugin')
const SRC_DIR = path.resolve(__dirname, 'src')
const DIST_DIR = path.resolve(__dirname, 'dist')
const NODE_DIR = path.resolve(__dirname, 'node_modules')
const isDev = process.env.NODE_ENV === 'development'
const config = {
mode: process.env.NODE_ENV,
entry: `${SRC_DIR}/main.js`,
devtool: isDev ? 'source-map' : 'none',
output: {
path: DIST_DIR,
publicPath: DIST_DIR,
filename: 'main.js',
},
resolve: {
extensions: ['.js'],
modules: [SRC_DIR, NODE_DIR],
alias: {
type: `${SRC_DIR}/type`,
},
},
module: {
rules: [
{
test: /\.js$/i,
exclude: [
/node_modules/,
/\.spec\.js/,
],
loader: 'eslint-loader',
options: {
fix: true,
cache: !isDev,
},
},
],
},
}
if (!isDev) {
config.optimization = {
minimize: true,
minimizer: [new TerserPlugin({
parallel: true,
})],
}
}
console.log('NODE_ENV', process.env.NODE_ENV)
console.log('devtool', config.devtool)
module.exports = config