npm install --save-dev postcss-loader

配置webpack.config.js

{
  test:/\.css$/,
  use:[
    'style-loader',
    'css-loader?importLoaders=1',
    'postcss-loader'
  ]
}

一种办法是配置postcss.config.js

module.exports = {
    plugins: [
        require('autoprefixer')({
          /* ...options */
        })
    ]
}

第二张办法是webpack.config.js使用LoaderOptionsPlugin

module.exports = {
    plugins: [
        new webpack.LoaderOptionsPlugin({
            options: {
                postcss: function(){
                    return [
                        require("autoprefixer")({
                            browsers: ['ie>=8','>1% in CN']
                        })
                    ]
                }
            }
        })
    ]
}

相关文章:

  • 2022-12-23
  • 2021-09-05
  • 2021-04-10
  • 2022-01-21
  • 2022-12-23
  • 2021-11-02
  • 2021-12-26
猜你喜欢
  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
  • 2022-12-23
  • 2021-04-09
  • 2021-10-02
相关资源
相似解决方案