使用的是extract-text-webpack-plugin,分离css,我现在是想修改css的时候页面能够自动编译并且刷新显示我修改了后的样式,经过查资料使用了css-hot-loader,但是还是没有效果,每次保存的时候也有自动编译css文件,但是就是没有变化。现在就是如果我修改了css,都要重新webpack一遍,才能看到变化。我的webpack中关于css的配置如下:
module: {
loaders: [{
test: /\.css$/,
exclude: /node_modules/,
use: ['css-hot-loader'].concat(ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
}))
}
},
new ExtractTextPlugin('static/css/style.css'),
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.css$/g,
cssProcessor: require('cssnano'),
cssProcessorOptions: {
discardComments: {
removeAll: true
}
},
canPrint: true
}),
以下是我的配置,可以参考,我觉得应该是配置写错了
module 部分相关代码
plugins 部分相关代码