为 PostCSS 设置配置文件
Setting Up a config file for PostCSS
我正在使用 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"
越来越长了。我看到提到 PostCSS 可以有一个配置文件 "postcss.config.js"。文中唯一提到的就是骨架:
module.exports = {
plugins: {
'autoprefixer': {},
'css-declaration-sorter': {}
}
};
uncss 文档仅针对选项说明:
{
html: ['index.html', 'about.html', 'team/*.html'],
ignore: ['.fade']
}
我希望有人有使用配置文件的经验来提供一些建议,因为我不相信这个功能有很好的文档记录。
您可以像这样在 postcss.config.js
文件中传递插件参数:
module.exports = {
plugins: [
require('module-name-1'),
require('module-name-2')({
option-a: 1,
option-b: "quoted value",
}),
],
};
我正在使用 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"
越来越长了。我看到提到 PostCSS 可以有一个配置文件 "postcss.config.js"。文中唯一提到的就是骨架:
module.exports = {
plugins: {
'autoprefixer': {},
'css-declaration-sorter': {}
}
};
uncss 文档仅针对选项说明:
{
html: ['index.html', 'about.html', 'team/*.html'],
ignore: ['.fade']
}
我希望有人有使用配置文件的经验来提供一些建议,因为我不相信这个功能有很好的文档记录。
您可以像这样在 postcss.config.js
文件中传递插件参数:
module.exports = {
plugins: [
require('module-name-1'),
require('module-name-2')({
option-a: 1,
option-b: "quoted value",
}),
],
};