postcss / postcss-custom-properties

Use Custom Properties in CSS
https://postcss.github.io/postcss-custom-properties
MIT License
597 stars 77 forks source link

Webpack example seems to be incorrect #241

Closed danielo515 closed 3 years ago

danielo515 commented 3 years ago

Reading the docs for post-css loader, this are the valid options:

module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: [
          "style-loader",
          "css-loader",
          {
            loader: "postcss-loader",
            options: {
              postcssOptions: {
                plugins: [
                  [
                    "postcss-preset-env",
                    {
                      // Options
                    },
                  ],
                ],
              },
            },
          },
        ],
      },
    ],
  },
};

But the docs at this repository says something different. What is the correct way of doing it? This seems to be the case for both webpack 4 and 5

danielo515 commented 3 years ago

In case anyone reads this, this is a working configuration:

          {
            loader: 'postcss-loader',
            options: {
              postcssOptions: {
                plugins: [postcssCustomProperties(/* pluginOptions */)],
              },
            },
          },
petertdinh commented 3 years ago

@danielo515 this was pretty helpful for me when I was upgrading from 7.0.0 to 11.0.0. You should consider making an MR to fix the webpack docs.