Webpack-dev-server 不重建包

Webpack-dev-server does not rebuild 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