-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
executable file
·44 lines (43 loc) · 1010 Bytes
/
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
const webpack = require('webpack')
const path = require('path')
const pkg = require('./package.json')
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
function generateConfig (config = {
minimize: false
}) {
const filename = `${pkg.name}${config.minimize ? '.min' : ''}.js`
const ret = {
entry: path.join(__dirname, '/src/index.js'),
devtool: 'source-map',
output: {
path: path.join(__dirname, '/dist'),
filename,
library: 'IDate',
libraryTarget: 'umd'
},
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader'
},
exclude: /node_modules/
}
]
},
plugins: []
}
if (config.minimize) {
ret.plugins.push(new webpack.optimize.UglifyJsPlugin({
minimize: true
}))
}
return ret
}
const ret = []
ret.push(generateConfig())
if (process.env.NODE_ENV === 'production') {
ret.push(generateConfig({minimize: true}))
}
module.exports = ret