Here is my css webpack config
{
test: /\.css$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: { sourceMap: true, importLoaders: 1 }
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
// https://github.com/postcss/postcss-loader/issues/92
// https://github.com/postcss/postcss-loader/issues/8
plugins: () => [
precss(),
postcssImport({ addDependencyTo: webpack }),
postcssNested(),
postcssCssnext({
browsers: ['last 2 versions', 'ie >= 9'],
compress: true,
}),
],
},
},
],
}
And I'm using Webpack 3, the hotloading feature doesn't work if I touch a css file that is an @import, people suggesed me to put postcssImport({ addDependencyTo: webpack })
to the first line of the plugin, but if I put before the precss, I got an compilation error.
I wonder if there is anything wrong with the above config, any help is appreciated.
You can reproduce the issue in this repo