-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.prod.js
62 lines (53 loc) · 1.48 KB
/
webpack.config.prod.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
const _ = require('lodash')
const webpack = require('webpack')
const config = require('./webpack.config.base.js')
// Merge with base configuration
//-------------------------------
_.merge(config, {
cache: false
})
delete config.output.libraryTarget
delete config.output.pathinfo
// Save files to disk
//-------------------------------
config.plugins.push(
new webpack.DefinePlugin({
'process.env.BLUEBIRD_WARNINGS': '0',
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compressor: {
screw_ie8: true,
warnings: false
}
})
)
// Sanity checks
//-------------------------------
if (config.devtool === 'eval') {
throw new Error('webpack: using "eval" source-maps may break the build')
}
// Compile everything for PROD
//-------------------------------
console.info('webpack: running production build...')
const compiler = webpack(config)
compiler.run(function(err, stats) {
if (err) throw err
// Output stats
console.log(stats.toString({
colors: true,
hash: false,
chunks: false,
version: false,
chunkModules: false
}))
if (stats.hasErrors()) {
console.warn('webpack: finished compiling webpack with errors...')
console.warn(stats.compilation.errors.toString())
} else {
console.info('webpack: finished compiling webpack')
}
})
module.exports = config