Postcss cannot be suffixed after using mini-css-extract-plugin

{
        test: /\.(sass|scss)$/,
        use: [{
            loader: MiniCssExtractPlugin.loader,
            options: {
              publicPath: "../"
            }
          },
          "css-loader",
          "postcss-loader",
          "sass-loader"
        ]
      },
      
      
    // postcss.config.js
     module.exports = {
  plugins: [
    require("autoprefixer"),
    // reuqire("postcss-import")
  ]

new MiniCssExtractPlugin({
      filename: "css/[name].[hash:6].css",
      // chunkFilename: "css/[name].[hash:6].css",

    }),
}

this question seems to have nothing to do with mini-css-extract-plugin, even if you switch to extract-text-plugins.
in postcss.config.js, you need to configure autoprefixer, or more accurately, set the compatibility range of the browser. By default, it will be selected in a certain range (you can't see how much it is by default, which may be > 5%).
solution: 1:

module.exports = {
  plugins: [
    require('autoprefixer')({
      browsers: ['cover 99.5% in CN']
    })
  ]
}

2: in official documents, it is more recommended to write in package.json or have a separate file to configure browserlist

  "browserslist": ["cover 99.5% in CN"]

this means 99.5% of browsers are covered, and the region is China. For more information, please see the Github documents of autoprefixer and browserslist

.

will

  

I hope the problem of the landlord has long been solved.
postcss.config.js just build it in the root directory. The second method can also change loader to object form in webpack.config.js. Add plugins: [require ('autoprefixer')] to the options option, and configure the browser scope prefix to be more complete.

Menu