【问题标题】:How to config Scss and purgeCss in Next js custom postCSS config如何在 Next js 自定义 postCSS 配置中配置 Scss 和 purgeCss
【发布时间】:2022-12-22 08:38:46
【问题描述】:

我正在使用Scss 和Bootstrap 来设计我的项目。为了删除未使用的 Css 和 purgeCss ,我自定义了我的 postcss.config.js 文件,如下所示:

module.exports = {
  plugins: [
    "postcss-flexbugs-fixes",
    [
      "postcss-preset-env",
      {
        autoprefixer: {
          flexbox: "no-2009",
        },
        stage: 3,
        features: {
          "custom-properties": false,
        },
      },
    ],
    [
      "@fullhuman/postcss-purgecss",
      {
        content: [
          "./pages/**/*.{js,jsx,ts,tsx}",
          "./components/**/*.{js,jsx,ts,tsx}",
        ],
        defaultExtractor: (content) => content.match(/[\w-/:]+(?<!:)/g) || [],
        safelist: ["html", "body"],
      },
    ],
  ],
};

问题是 postCss 忽略了我的 Scss 文件并且没有显示样式。 如何将Scss 添加到postcss.config.js 文件?

【问题讨论】:

    标签: javascript css next.js postcss css-purge


    【解决方案1】:

    问题来自@fullhuman/postcss-purgecss。 你可以删除它。

     [
          "@fullhuman/postcss-purgecss",
          {
            content: [
              "./pages/**/*.{js,jsx,ts,tsx}",
              "./components/**/*.{js,jsx,ts,tsx}",
            ],
            defaultExtractor: (content) => content.match(/[w-/:]+(?<!:)/g) || [],
            safelist: ["html", "body"],
          },
        ],
    

    然后再次使用 scss。或者您可以更改有关内容的设置。

    【讨论】:

      猜你喜欢
      • 2022-01-16
      • 2020-01-07
      • 1970-01-01
      • 2017-08-16
      • 2018-11-25
      • 1970-01-01
      • 2020-12-06
      • 2018-12-11
      • 1970-01-01
      相关资源
      最近更新 更多