-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
53 lines (46 loc) · 1.06 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
const path = require('path')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
module.exports = function () {
const isProd = process.env.NODE_ENV === 'production'
const isPolyfill = process.env.POLYFILL
const isClean = process.env.CLEAN
let filename = 'jxmath.js'
let rules = []
let plugins = []
if (isClean) {
plugins.push(new CleanWebpackPlugin()) // 清除上一次打包内容
}
if (isPolyfill) {
filename = 'jxmath.polyfill.min.js'
} else if (isProd) {
filename = 'jxmath.min.js'
}
if (isPolyfill) {
rules = [
{
test: /\.js$/,
use: 'babel-loader',
exclude: '/node_modules/'
}
]
}
const config = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename,
library: 'jxm',
libraryTarget: 'umd',
libraryExport: 'default',
globalObject: 'typeof window !== "undefined" ? window : this'
},
plugins,
optimization: {
minimize: isProd
},
module: {
rules
}
}
return config
}