Ich kann CSS-Module zu arbeiten, aber nicht in den Heiß-Neuladen.Webpack-dev-Server und CSS-Module
Wenn zuerst geladen, wird die Art, wie es sein sollte:
Aber nachdem es bricht Änderungen an der CSS-Datei zu machen und eine vollständige Nachladen benötigt:
ich bin mit der CSS-Module wie folgt:
webpack.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const pack = {
entry: [
path.join(__dirname, 'src/app/index.js'),
],
output: {
path: path.join(__dirname, '/dist/'),
filename: '[name].js',
publicPath: '/',
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/app/index.html',
inject: 'body',
filename: 'index.html',
}),
],
module: {
loaders: [
{
test: /\.css$/,
include: /src\/app/,
loaders: [
'style?sourceMap',
'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
],
},
{
test: /\.js?$/,
include: /src\/app/,
loader: 'babel',
},
{
test: /\.woff(2)?(\?[a-z0-9#=&.]+)?$/,
loader: 'url?limit=10000&mimetype=application/font-woff',
},
{
test: /\.(ttf|eot|svg)(\?[a-z0-9#=&.]+)?$/,
loader: 'file',
},
],
},
};
module.exports = pack;
webpack.development.config.js
const webpack = require('webpack');
const pack = require('./webpack.config');
pack.entry.unshift('react-hot-loader/patch');
pack.entry.unshift('webpack/hot/only-dev-server');
pack.entry.unshift('webpack-dev-server/client?http://localhost:3000');
pack.plugins.push(new webpack.HotModuleReplacementPlugin());
pack.plugins.push(new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development'),
}));
module.exports = pack;
Wie ich bemerkt, die CSS-Klasse, dass es in der Komponente zu holen versucht Stills das gleiche, sollte nicht für jede Datei Änderung/Neuladen ein neuer Hash generiert werden?
Haben Sie in Ihren Quellen eine 'module.accept()' Anweisung hinzugefügt? –
Nein ... Ich habe es gelöst, indem ich 'pack.entry.unshift ('webpack/hot/only-dev-server');' zu 'pack.entry.unshift ('webpack/hot/dev-server');' . Es hat alles aktualisiert, aber aktualisiert das CSS wie erwartet. –
Das könnte erklären, warum Sie eine vollständige Aktualisierung erhalten. –