How to use autoprefixer
with webpack 2.x.
Previously, it used to be something like this...
...
module: {
loaders: [
{
test:
webpack 2.x.x
introduced webpack.LoaderOptionsPlugin()
plugin where you need to define all the loader option plugins. Like, autoprefixer
is a plugin for postcss-loader
. So, it has to go here.
And
module.rules
replaces module.loaders
loader: 'style!css'
should be loader: 'style-loader!css-loader'
The new config will look something like this...
...
module: {
rules: [
{
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'sass-loader', 'postcss-loader']
}
]
},
plugins: [
new webpack.LoaderOptionsPlugin({
options: {
postcss: [
autoprefixer(),
]
}
})
],
...
Hope this helps everyone.