【问题标题】:Setting Up a config file for PostCSS为 PostCSS 设置配置文件
【发布时间】:2019-07-14 07:00:45
【问题描述】:

我正在使用 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']
}

我希望如果有人有使用配置文件的经验,可以提供一些建议,因为我不相信这个功能有很好的文档记录。

【问题讨论】:

    标签: html css postcss


    【解决方案1】:

    您可以像这样在postcss.config.js 文件中传递插件参数:

    module.exports = {
        plugins: [
            require('module-name-1'),
            require('module-name-2')({
                option-a: 1,
                option-b: "quoted value",
            }),
        ],
     };
    

    【讨论】:

    • 感谢您的意见。
    猜你喜欢
    • 2020-12-06
    • 2017-08-16
    • 2019-10-27
    • 1970-01-01
    • 2018-11-27
    • 2018-09-17
    • 1970-01-01
    • 1970-01-01
    • 2021-04-07
    相关资源
    最近更新 更多