webpack打包插件

13次阅读

共计 735 个字符,预计需要花费 2 分钟才能阅读完成。

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
}
})
]

正文完
 0