-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
62 lines (54 loc) · 1.27 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
var webpack = require('webpack')
var path = require('path')
var pkg = require('./package.json')
var util = require('util')
var NODE_ENV = process.env.NODE_ENV // production, development, test
var TEST = 'test' == NODE_ENV
var DEBUG = 'development' == NODE_ENV
var PRODUCTION = true
if (TEST) {
console.log('test mode')
DEBUG = true // test mode also use debug mode
}
if (DEBUG) {
console.log('debug mode')
PRODUCTION = false
}
if (PRODUCTION) {
console.log('production')
}
var config = {
entry: {
'min-util': './'
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
libraryTarget: 'umd',
library: '_'
},
plugins: [
new webpack.optimize.DedupePlugin(),
new webpack.BannerPlugin(util.format('%s@%s by %s', pkg.name, pkg.version, pkg.author)),
new webpack.DefinePlugin({
VERSION: JSON.stringify(pkg.version),
DEBUG: DEBUG
})
]
}
if (TEST) {
var dir = path.join(__dirname, 'test/public')
config.entry = './test/index.js'
config.output.filename = 'tests.js'
config.output.path = dir
config.devServer.contentBase = dir
}
if (DEBUG) {
config.devtool = 'source-map'
}
if (PRODUCTION) {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({minimize: true})
)
}
module.exports = config