我正在使用 PostCSS,我想添加 Post-uncss。我不使用任务运行器,只使用 Postcss-cli。我的 package.json 现在看起来像这样:
"css-clean": "npx postcss src\\css\\main.css -u autoprefixer --replace && npx postcss src\\css\\main.css -u css-declaration-sorter --replace --no-map"
Run Code Online (Sandbox Code Playgroud)
它变得相当长。我看到提到 PostCSS 可以有一个配置文件“postcss.config.js”。文章中唯一提到的就是骨架:
module.exports = {
plugins: {
'autoprefixer': {},
'css-declaration-sorter': {}
}
};
Run Code Online (Sandbox Code Playgroud)
uncss 文档只说选项:
{
html: ['index.html', 'about.html', 'team/*.html'],
ignore: ['.fade']
}
Run Code Online (Sandbox Code Playgroud)
我希望如果有人有使用配置文件的经验来提供一些建议,因为我不相信这个功能是有据可查的。
您可以在postcss.config.js文件中传递插件参数,如下所示:
module.exports = {
plugins: [
require('module-name-1'),
require('module-name-2')({
option-a: 1,
option-b: "quoted value",
}),
],
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3334 次 |
| 最近记录: |