webpack.config.js====插件purifycss-webpack,提炼css文件

1. 安装:打包编译时,可以删除一些html中没有使用的选择器,如果html页面中没有class=a class="b"的元素,.a{}.b{}样式不会加载

cnpm install --save-dev purifycss-webpack purify-css glob

2. webpack.config.js中使用

const purifycssWebpack = require('purifycss-webpack');
const glob = require('glob');

 

 
 

//一定要放在htmlWebpackPlugin后面
new purifycssWebpack({
  paths: glob.sync(path.resolve('./src/*.html'))
}),

 

 

猜你喜欢

转载自www.cnblogs.com/songxia/p/10295783.html