-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
46 lines (40 loc) · 1.25 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
const webpack = require('webpack');
const base = require('./webpack.base.config');
const vueConfig = require('./vue-loader.config');
//生成 前端文件的webpack 配置
const config = Object.assign({}, base, {
devtool: 'source-map',
plugins: (base.plugins || []).concat([
// strip comments in Vue code
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
}),
//将类库文件进行分开打包,便于缓存
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: 'client-vendor-bundle.js'
})
]),
watch: true
})
if (process.env.NODE_ENV === 'production') {
vueConfig.loaders = {
css: ExtractTextPlugin.extract({
loader: "css-loader!stylus-loader",
fallbackLoader: "vue-style-loader" // <- this is a dep of vue-loader
})
}
config.plugins.push(
// this is needed in webpack 2 for minifying CSS
new webpack.LoaderOptionsPlugin({
minimize: true
}),
// minify JS
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
)
}
module.exports = config