How to disable hot module replacement in webpack for production

Viewed 9226

How does one remove all references of HMR when bundling for production?

My production Webpack config has no references to HMR and yet in the browser debugger the client is constantly making a xhr call to /__webpack_hmr

Can anyone shed a light on this?

-- my config

var path = require('path');
var webpack = require('webpack');

module.exports = {
entry: [
      path.resolve(__dirname, 'master/jsx/App')
    ],
    output: {
        path: path.resolve(__dirname, 'build'),
        publicPath: '/dist/',
        filename: 'app.bundle.js'
    },
    cache: false,
    devtool: 'sourcemap',
    resolve: {
        extensions: ['', '.js', '.jsx']
    },
    plugins: [
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.DefinePlugin({
            'process.env.NODE_ENV': '"production"'
        }),
        new webpack.optimize.UglifyJsPlugin({
            compressor: {
                warnings: false
            }
        })
    ],
    module: {
        loaders: [{
            test: /\.jsx?$/,
            exclude: /node_modules/
        }, {
            test: /\.jsx?$/,
            exclude: /node_modules/,
            loader: 'babel',
            query: {
                presets: ['es2015', 'react'],
                compact: false
            }
        }, {
            test: /\.css$/,
            loader: "style-loader!css-loader"
        }, {
            test: /\.woff|\.woff2|\.svg|.eot|\.ttf/,
            loader: 'url?prefix=font/&limit=10000'
        }]
    }
};
4 Answers

You might try making sure all of the browser windows you have open to your website are using an updated bundle.

I was having the same problem, except in my case I saw the GET /__webpack_hmr calls on my server because I made my server print all the request methods and paths.

Turns out, I had a different browser window open that I hadn't noticed, which was running my dev bundle; it was making the requests.

Related