0

配置

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')
  ]
}

包.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 站点上的基本示例

4

1 回答 1

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')
于 2018-02-04T23:39:23.773 回答