Ich versuche, webpack-dev-server zu verwenden, um eine Hot-Reload-Funktion für JS- und SCSS-Dateien zu haben, aber es funktioniert nicht. Ich halte die gleichen Fehler:Fehler beim Warmladen mit babel, webpack und sass
[WDS] App updated. Recompiling...
[WDS] App hot update...
[HMR] Checking for updates on the server...
[HMR] The following modules couldn't be hot updated: (They would need a full reload!)
[HMR] - 381
[HMR] Nothing hot updated.
[HMR] App is up to date.
Ich habe meine /dist/main.css hinzugefügt und /dist/main.js Dateien auf meine index.html, und der Rest ist wie folgt:
Mein server.js ist:
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const config = require('./webpack.config');
new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: true,
historyApiFallback: true
}).listen(3000, 'localhost', function (err, result) {
if (err) {
return console.log(err);
}
console.log('Listening at http://localhost:3000/');
});
Meine webpack.config Datei ist:
const sassLoaders = [
'css-loader?minimize!',
'postcss-loader',
'sass-loader?includePaths[]=' + path.resolve(__dirname, './src/css')
]
module.exports = {
entry: [
'babel-polyfill',
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
path.normalize(__dirname + '/src/js/main'),
path.normalize(__dirname + '/src/css/styles.scss')
],
devtool: 'cheap-module-source-map',
output: {
filename: '[name].js',
path: path.join(__dirname, './dist'),
publicPath: '/dist'
},
module: {
loaders: [
{
loader: 'babel',
test: /\.js$/,
include: [path.resolve(__dirname, 'src', 'js')],
query: {
plugins: ['transform-runtime'],
presets: ['es2015']
}
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', sassLoaders.join('!'))
}
]
},
plugins: [
new ExtractTextPlugin('[name].css'),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false }
}),
new webpack.HotModuleReplacementPlugin()
],
postcss: [
autoprefixer({
browsers: ['last 2 versions']
})
],
resolve: {
extensions: ['', '.js', '.scss'],
root: [path.join(__dirname, './src')]
}
};
Thank you!