plugins:[
new webpack.DefinePlugin({ //生成模式
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.CommonsChunkPlugin({name:'vendors',filename:'src/assets/js/vendors.js'}), //提出公用模块
new webpack.optimize.UglifyJsPlugin({ //混淆js
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({ //压缩css,自动补全前缀
options:{
postcss: function () {
return [precss,autoprefixer];
},
minimize: true
}
}),
new HtmlWebpackPlugin({ //生成html模版
filename: 'index.html',
template:__dirname+'/my-index.html',
inject:'body',
hash:true
}),
new CleanWebpackPlugin(['dist'],{ //清楚已打包
verbose: true,
dry: false,
}),
new ExtractTextPlugin('src/assets/css/[name].[chunkhash:8].css') //单独提出css打包
]