3
votes

I have the next config for webpack loaders:

 module: {
    loaders: [{
      test: /\.js$/,
      include: rootDir + '/src',
      loader: 'babel?presets[]=es2015'
    }, {
      test: /\.css$/,
      loader: 'style!css!autoprefixer?browsers=last 2 versions'
    }, {
      test: /\.(png|gif|jpg|svg|ttf|eot|woff|woff2)$/,
      loader: 'file?name=[path][name].[ext]'
    }]
  }

I want to exclude some files from autoprefixer loader. How can I do this? If I do like this:

{
  test: /\.css$/,
  exclude: 'someFile',
  loader: 'style!css!autoprefixer?browsers=last 2 versions'
}

someFile will be excluded not only from autoprefixer loader, it will be excluded from styles, css and autoprefixer loader, but I need exclude file only from autoprefixer loader. How can I do this?

1

1 Answers

2
votes

You're on the right track. Create two loader configurations, one for 'somefile', and one for the rest of your CSS files that excludes 'somefile':

module: {
  loaders: [
  ...
  {
    test: 'somefile',
    loader: 'style!css'
  }, {
    test: /\.css$/,
    loader: 'style!css!autoprefixer?browsers=last 2 versions',
    exclude: 'somefile'
  },
  ...
  ]
}