使用postcss autoprefixer时,Webpack配置加载器错误

时间:2016-06-24 01:43:10

标签: css reactjs webpack webpack-dev-server

所以我一直在使用带有加载器的webpack。今天我想在css中添加一个前缀加载器,并且我在webpack开发服务器运行时不断收到错误"无法解析模块postcss"这是代码:

  module: {
    loaders: [
      {test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'},
      {test: /\.css$/, loader: 'style!css?{"sourceMap&modules&localIdentName": "[name]__[local]___[hash:base64:5]", "modules&importLoader": "1!postcss"}'}
    ]
  },
  postcss: [ autoprefixer({ browsers: ['last 2 versions'] }) ]

之前我只使用下面的代码,我的webpack run dev server命令运行没有错误。

  module: {
    loaders: [
      {test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'},
      {test: /\.css$/, loader: 'style!css?sourceMap&modules&localIdentName=[name]__[local]___[hash:base64:5]'}
    ]
  }

我做错了什么?

1 个答案:

答案 0 :(得分:0)

解决了它:

  module: {
    loaders: [
      {test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'},
      {test: /\.css$/, loader: 'style!css?sourceMap&modules&localIdentName=[name]__[local]___[hash:base64:5]&importLoader=1!postcss'}
    ]
  },
  postcss: [ autoprefixer({ browsers: ['last 2 versions'] }) ]