Do you want to request a feature or report a bug?
Feature
What is the current behavior?
There doesn't seem to be a way to disable auto reload: http://stackoverflow.com/questions/41797704/how-to-disable-webpack-dev-server-auto-reload
What is the expected behavior?
Add ability to disable auto reload so changes to files do not trigger automatic reload
Answered your question on StackOverflow.
Unfortunately it did not work. I added my comments to the SO thread.
That doesn't work for me either. Every time I edit a meaningless comment line and save, I get [WDS] App updated. Recompiling... in the browser and it forces a refresh.
EDIT: Sorry, nvm. Adding a command line param didn't help, because webpack config overwrote it. Changing that config file helped.
hello, this is still not working for me! can you please help, how to disable auto-reload?
Can this issue please be reopened? We just upgraded to from Webpack 1 to Webpack 2 and this change in the latest webpack-dev-server is extremely disruptive to our workflow. We need to be able to work on our code without constantly causing our page to reload.
@jk21, @Ghazgkull - ~please try mixing this in with your webpack.config.js~
config.devServer = {
hot: false,
inline: false,
}
~Plus, if you have any custom components for hot reload for your framework (Angular, React...), remove or comment out those as well. Hope this helps!~
EDIT: Sorry, I just realized for that particular project where I tried this, we still had [email protected]. :(
I'm working around this using @pawelpabich's suggestion from StackOverflow:
npm install --save-dev null-loaderconst path = require('path');
[...]
module.exports = {
[...]
module: {
rules: {
[...]
{ // Disable webpack-dev-server's auto-reload feature in the browser.
test: path.resolve(__dirname, 'node_modules/webpack-dev-server/client'),
loader: 'null-loader'
}
}
}
Using webpack-dev-server 2.5 and webpack 2.6.1,
config.devServer = {
hot: false,
inline: false,
}
worked for me.
Based on @jcrben's comment, I just tried updating webpack-dev-server from 2.4.5 to 2.5.0 (with webpack 2.6.1) and the problem does indeed appear to be fixed.
config.devServer = {
hot: false,
inline: false,
}
Worked fine!!
How do I add
config.devServer = {
hot: false,
inline: false,
}
to this
// @remove-on-eject-begin
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// @remove-on-eject-end
'use strict';
// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = 'development';
process.env.NODE_ENV = 'development';
// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on('unhandledRejection', err => {
throw err;
});
// Ensure environment variables are read.
require('../config/env');
const fs = require('fs');
const chalk = require('chalk');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const clearConsole = require('react-dev-utils/clearConsole');
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
const {
choosePort,
createCompiler,
prepareProxy,
prepareUrls,
} = require('react-dev-utils/WebpackDevServerUtils');
const openBrowser = require('react-dev-utils/openBrowser');
const paths = require('../config/paths');
const config = require('../config/webpack.config.dev');
const createDevServerConfig = require('../config/webpackDevServer.config');
const useYarn = fs.existsSync(paths.yarnLockFile);
const isInteractive = process.stdout.isTTY;
// Warn and crash if required files are missing
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
process.exit(1);
}
// Tools like Cloud9 rely on this.
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3001;
const HOST = process.env.HOST || '0.0.0.0';
// We attempt to use the default port but if it is busy, we offer the user to
// run on a different port. `detect()` Promise resolves to the next free port.
choosePort(HOST, DEFAULT_PORT)
.then(port => {
if (port == null) {
// We have not found a port.
return;
}
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
const appName = require(paths.appPackageJson).name;
const urls = prepareUrls(protocol, HOST, port);
// Create a webpack compiler that is configured with custom messages.
const compiler = createCompiler(webpack, config, appName, urls, useYarn);
// Load proxy config
const proxySetting = require(paths.appPackageJson).proxy;
const proxyConfig = prepareProxy(proxySetting, paths.appPublic);
// Serve webpack assets generated by the compiler over a web sever.
const serverConfig = createDevServerConfig(
proxyConfig,
urls.lanUrlForConfig
);
const devServer = new WebpackDevServer(compiler, serverConfig);
// Launch WebpackDevServer.
devServer.listen(port, HOST, err => {
if (err) {
return console.log(err);
}
if (isInteractive) {
clearConsole();
}
console.log(chalk.cyan('Starting the development server...\n'));
openBrowser(urls.localUrlForBrowser);
});
['SIGINT', 'SIGTERM'].forEach(function(sig) {
process.on(sig, function() {
devServer.close();
process.exit();
});
});
})
.catch(err => {
if (err && err.message) {
console.log(err.message);
}
process.exit(1);
});
The most stupid thing I ever saw
For anyone still looking for this, you can configure webpack-dev-server in config/webpack/development.js, e.g.
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
const environment = require('./environment');
environment.config.merge({
devServer: {
hot: false,
inline: false,
liveReload: false
}
});
module.exports = environment.toWebpackConfig();
Interesting if we can turn off/on live-reload in webpack-dev-server dynamically without restarting
If you (like me) are concerned about the server capturing and recompiling all changes in the background - while it's not being used by the frontend (auto-reload disabled), try:
serverConfig.watchOptions.ignored = [/.*/];
where serverConfig usually comes from your webpack dev-server config file (mine, on React, is config/webpackDevServer.config.js)
Of course, with this, there's no need to disable auto-reload anyway - as the recompilation stops completely :)
@janakaud But, this method just stops the compiling job.
@FrankFang that was the whole point - what's the possible use of the compiler running, when auto-reload is disabled (i.e. the compiled result is not being used by anyone)? 馃檪
The whole point is to be able to disable or enable it when it is needed w/o process restart (and w/o turning off autosave in ide)
Well that's your opinion - neither the title nor the issue description states "to be able to disable or enable it when it is needed" or "w/o process restart"; rather, it says "to disable auto reload so changes to files do not trigger automatic reload"
In my case I just wanted to run the dev server with reloading disabled (launch, compile once, and keep on serving; so that every single tune-up I do in the code, does not fire a useless 100%-cpu recompile cycle); and that's easily achieved by the above serverConfig.watchOptions.ignored config change. Hope this helps someone who comes here, hunting for the same quest! 馃檹
Most helpful comment
Using webpack-dev-server 2.5 and webpack 2.6.1,
worked for me.