Webpack 为什么HMR和chunkhash不能一起使用?

Webpack 为什么HMR和chunkhash不能一起使用?,webpack,webpack-hmr,Webpack,Webpack Hmr,我知道在webpack.config.js中,HMR插件和chunkhash不能一起使用。但我不知道为什么。有人能给我解释一下吗 错误代码是: const webpack = require("webpack"); const HtmlWebpackPlugin = require("html-webpack-plugin"); module.exports = { devtool: "eval-source-map", entry: __dirname + "/app/ma

我知道在
webpack.config.js
中,HMR插件和chunkhash不能一起使用。但我不知道为什么。有人能给我解释一下吗

错误代码是:

const webpack = require("webpack");
const HtmlWebpackPlugin =  require("html-webpack-plugin");

module.exports = {
    devtool: "eval-source-map",
    entry: __dirname + "/app/main.js",
    output: {
        path: __dirname + "/build",
        filename: "bundle-[chunkhash].js"//改为“bundle.js”及为正确的代码
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: __dirname + "/app/index.tmp1.html"
        }),
        new webpack.HotModuleReplacementPlugin(),
    ],
}

有了HMR,数据块保存在内存中,永远不会发送到磁盘。真的没有理由要散列。现在,当您转到生产环境时,您希望该哈希用于缓存破坏目的。退房它正在使用HMR,在中,您可以看到它是通过以下方式处理的:

filename: devMode ? '[name].js' : '[name].[hash].js',
chunkFilename: devMode ? '[name].js' : '[name].[chunkhash].js',