-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathwebpack.config.js
81 lines (72 loc) · 1.31 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
/*
# 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 entryPath = path.join(
__dirname,
'themes',
'learn-plasma',
'src',
'index.js'
)
let outputPath = path.join(__dirname, 'themes', 'learn-plasma', 'source')
if (env !== 'development') {
env = 'production'
prd = true
}
let opts = {
target: 'web',
mode: env,
entry: entryPath,
output: {
path: outputPath,
filename: 'index.js'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {presets: ['@babel/preset-env']}
}
]
},
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