-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
73 lines (62 loc) · 1.22 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
/*
# webpack config
https://webpack.js.org
https://webpack.js.org/configuration
*/
let path = require('path')
let UglifyjsWebpackPlugin = require('uglifyjs-webpack-plugin')
let env = process.env.NODE_ENV
let dev = env === 'development'
let prd = env === 'production'
let srcPath = path.join(__dirname, 'src')
let backgroundPath = path.join(srcPath, 'background.js')
let popupPath = path.join(srcPath, 'popup.js')
let distPath = path.join(__dirname, 'dist')
if (env !== 'development') {
env = 'production'
prd = true
}
let opts = {
target: 'web',
mode: env,
entry: {
background: backgroundPath,
popup: popupPath
},
output: {
path: distPath,
filename: '[name].js'
},
watch: false,
cache: dev,
performance: {
hints: false
},
stats: {
assets: false,
colors: dev,
errors: true,
errorDetails: true,
hash: false
}
}
if (dev === true) {
opts.devtool = 'source-map'
}
if (prd === true) {
opts.optimization = {
minimize: true,
minimizer: [
new UglifyjsWebpackPlugin({
sourceMap: false,
uglifyOptions: {
ecma: 5,
mangle: true,
compress: true,
warnings: false
}
})
]
}
}
module.exports = opts