uglifyjs-webpack-plugin

压缩代码,webpack自带

const uglify = require('uglifyjs-webpack-plugin');

plugins:[
    new uglify()
]

html-webpack-plugin

需要安装

new htmlPlugin({
	minify:{
		removeAttributeQuotes:true,//去掉属性的引号
	},
	hash:true,
	template:'./src/index.html'
})

extract-text-webpack-plugin

css分离到指定文件

new extractTextPlugin('css/index.css') //指定出口

{
    test:/\.css$/,
    use:extractTextPlugin.extract({
        fallback:'style-loader',
        use:[{
            loader:'css-loader'
        }]
    })
}

purifycss-webpack

净化css,不会打包没有dom元素的css样式
Q: 如果通过动态添加类名,则可能不适用该插件
Note:如果没有extract-text-webpack-plugin,可能会报错
npm i -D purifycss-webpack prufi-css

new PurifyCSSPlugin({
    paths:glob.sync(path.join(__dirname,'src/*.html'))
})

相关文章:

  • 2021-10-01
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2022-01-01
猜你喜欢
  • 2021-12-08
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
相关资源
相似解决方案