我正在尝试从我的一个或多个 sass 文件中删除未使用的 css 规则。
如果您不使用服务器端渲染,研究使我将 postcss-uncss 作为删除未使用 css 的最佳选择(请参阅:https ://www.purgecss.com/comparison )
https://github.com/uncss/postcss-uncss
现在,postcss-uncss 是 uncss 的包装器:https ://github.com/uncss/uncss 但是,uncss 文档让我感到困惑,这里的示例配置没有用:https ://github.com/uncss /postcss-uncss#example-configuration
如何为 Laravel Mix 配置 postcss-uncss?
这是我到目前为止所拥有的:
mix.js('resources/js/app.js', 'public/js')
.options({
processCssUrls: false,
postCss: [
require('postcss-uncss'),
tailwindcss('./tailwind.config.js')
],
})
我想要:
- 告诉它要使用哪些 laravel 路由(或“全部”也应该没问题)
- 我的 sass / scss 文件所在的位置:/resources/sass/*(示例文件:/resources/sass/app.scss、/resources/sass/admin/admin.scss 等)
- 在哪里放置输出,即没有未使用规则的编译(和清理)css:/public/css/*(以保持相同的结构,例如:/public/app.css、/public/admin/admin .css 等)
想法将不胜感激。