const path = require(‘path’); //引入node的path模块const webpack = require(‘webpack’); //引入的webpack,使用lodashconst HtmlWebpackPlugin = require(‘html-webpack-plugin’) //将html打包const ExtractTextPlugin = require(‘extract-text-webpack-plugin’) //打包的css拆分,将一部分抽离出来 const CopyWebpackPlugin = require(‘copy-webpack-plugin’)// console.log(path.resolve(__dirname,’dist’)); //物理地址拼接
优化打包速度constUglifyJsPlugin= require(‘uglifyjs-webpack-plugin’);压缩代码,这里使用的是uglifyjs-webpack-plugin,同样在webpack.config.js的plugin里面添加
constUglifyJsPlugin= require(‘uglifyjs-webpack-plugin’);
plugins:[
new UglifyJsPlugin({
uglifyOptions: {
output: {
beautify: false,
comments: false,
},
compress: {
warnings: false,
drop_debugger: true,
drop_console: true,
pure_funcs: [‘console.log’, ‘(e = console).log’ ]
},
sourceMap: false
}
})
]
本文由乐趣区整理发布,转载请注明出处,谢谢。