Webpack开发服务器未重新生成bundle



非常奇怪的时刻。我有:

webpack.hmr.config.js

// webpack.hmr.config.js
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebpackChunkHash = require('webpack-chunk-hash');
const commonExportsObject = require('./webpack.common.config');
const commonEnv = commonExportsObject.commonEnv;
const path = require('path');
module.exports = {
devtool: 'eval-source-map',
mode: 'development',
entry: [
'babel-polyfill',
'react-hot-loader/patch',
'./src/index',
],
output: {
path: path.join(__dirname, '/build/'),
filename: 'main.js',
publicPath: '/',
},

resolve: {
modules: [
path.join(__dirname, './src'),
'node_modules',
],
},
module: {
rules: [
{
test: /.js$/,
loaders: [
{
loader: 'babel-loader',
options: {
babelrc: false,
presets: ['react', ['es2015', { modules: false }], 'stage-3'],
plugins: ['react-hot-loader/babel', 'transform-class-properties'],
},
},
],
exclude: /node_modules/,
},
{
test: /.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /.scss$/,
exclude: /node_modules/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /.(png|jpg|gif|eot|ttf|woff|woff2|svg).*$/,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
},
},
],
},
],
},
plugins: [
new WebpackChunkHash({ algorithm: 'md5' }),
new HtmlWebpackPlugin({
inject: 'body',
filename: 'index.html',
template: './src/index.html',
}),
new webpack.DefinePlugin({
'process.env': Object.assign({}, commonEnv),
}),
new webpack.HotModuleReplacementPlugin(),
],
optimization: {
namedModules: true,
noEmitOnErrors: true,
},
};

服务器hmr.js

//server-hmr.js
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const config = require('./webpack.hmr.config');
const options = {
noInfo: true,
compress: true,
contentBase: 'build',
historyApiFallback: true,
hot: true,
port: 3000,
host: 127.0.0.1,
proxy: [{
context: ['/api', '/static', '/temp_admin'],
target: 'http://127.0.0.1:8000/',
secure: false,
}],
};
WebpackDevServer.addDevServerEntrypoints(config, options);
const compiler = webpack(config);
new WebpackDevServer(compiler, options).listen(3000, '127.0.0.1', (err) => {
if (err) {
console.error(err);
}
});

运行它:节点服务器hmr.js.

在控制台中:-[HMR]正在等待WDS的更新信号。。。-[WDS]热模块更换已启用。

我更改了一些文件,但捆绑包没有重建。(很少是这样的——文件是一样的(。

我不知道为什么,请帮帮我。有什么想法吗?

节点-8.9.1,"webpack dev-server":"^3.1.5","webpack":"^4.16.3",

需要更多内存:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

相关内容

  • 没有找到相关文章

最新更新