postcss-loader与webpack 3中的ExtractTextPlugin不兼容?

时间:2018-01-29 03:28:47

标签: postcss webpack-3 extract-text-plugin postcss-loader

配置

webpack.config.js

test: /\.css$/,
exclude: /node_modules/,
use: ExtractTextPlugin.extract({
      fallback: 'style-loader',
      use: [
        {
          loader: 'css-loader',
          options: { importLoaders: 1 }
        },
        'postcss-loader'
      ]
    })

...

new ExtractTextPlugin('../css/[name].bundle.css')

postcss.config.js

module.export = {
  plugins: [
    require('autoprefixer')
  ]
}

的package.json

"webpack": "^3.10.0",
"css-loader": "^0.28.9",
"style-loader": "^0.20.1",   
"extract-text-webpack-plugin": "^3.0.2",
"postcss-loader": "^2.0.10",
"autoprefixer": "^7.2.5",

其他信息

$ node -v
v9.4.0

问题

运行此配置时,我没有错误。它运行就好像postcss-loader不存在并给我简单的CSS。我正在尝试运行autoprefixer site

上发布的基本示例

1 个答案:

答案 0 :(得分:0)

webpack.config.js

test: /\.css$/,
  exclude: /node_modules/,
    use: ExtractTextPlugin.extract({
      fallback: 'style-loader',
      use: [
        'css-loader',
        {
          loader: 'postcss-loader',
          options: {
            plugins: () => [
              require('autoprefixer')
            ]
          }
        }
      ]
    })

...

new ExtractTextPlugin('/css/[name].bundle.css')