webpack打包插件

const path = require('path'); //引入node的path模塊
const webpack = require('webpack'); //引入的webpack,使用lodash
const 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')); //物理地址拼接css

優化打包速度
constUglifyJsPlugin= require('uglifyjs-webpack-plugin');
壓縮代碼,這裏使用的是uglifyjs-webpack-plugin,一樣在webpack.config.js的plugin裏面添加html

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
          }
    })
]
相關文章
相關標籤/搜索