react 项目 目录结构如下
public
|-index.html
|-theme.css
index.html 中引入了 theme.css
现在想在 webpack 打包的时候 自动压缩css 能实现吗?
react 项目 目录结构如下
public
|-index.html
|-theme.css
index.html 中引入了 theme.css
现在想在 webpack 打包的时候 自动压缩css 能实现吗?
通过 mini-css-extract-plugin 提取 Chunk 中的 CSS 代码到单独文件,通过 css-loader 的 minimize 选项开启 cssnano 压缩 CSS。
10 回答11.7k 阅读
2 回答3.2k 阅读✓ 已解决
2 回答4.3k 阅读✓ 已解决
3 回答1.9k 阅读✓ 已解决
2 回答1.7k 阅读✓ 已解决
4 回答2.5k 阅读✓ 已解决
5 回答3.8k 阅读
要引入插件
optimize-css-assets-webpack-plugin
optimize-css-assets-webpack-plugin
一般来说不需要复杂的配置