Skip to content

Commit a77eac5

Browse files
committed
Merge pull request #439 from SimenB/hot-only
Add hot-only option to allow setting `only-dev-server` from cli or config
2 parents 991f2aa + 6dc80ec commit a77eac5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

bin/webpack-dev-server.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var yargs = require("yargs")
2323

2424
require("webpack/bin/config-yargs")(yargs);
2525

26+
var ADVANCED_GROUP = "Advanced options:";
2627
var DISPLAY_GROUP = "Stats options:";
2728
var SSL_GROUP = "SSL options:";
2829
var CONNECTION_GROUP = "Connection options:";
@@ -38,6 +39,11 @@ yargs.options({
3839
default: true,
3940
describe: "Inline mode"
4041
},
42+
"hot-only": {
43+
type: "boolean",
44+
describe: "Do not refresh page if HMR fails",
45+
group: ADVANCED_GROUP
46+
},
4147
"stdin": {
4248
type: "boolean",
4349
describe: "close when stdin ends"
@@ -169,6 +175,9 @@ function processOptions(wpOpt) {
169175
if(!options.hot)
170176
options.hot = argv["hot"];
171177

178+
if(!options.hotOnly)
179+
options.hotOnly = argv["hot-only"];
180+
172181
if(argv["content-base"]) {
173182
options.contentBase = argv["content-base"];
174183
if(/^[0-9]$/.test(options.contentBase))
@@ -231,8 +240,11 @@ function processOptions(wpOpt) {
231240
if(options.inline !== false) {
232241
var devClient = [require.resolve("../client/") + "?" + protocol + "://" + (options.public || (options.host + ":" + options.port))];
233242

234-
if(options.hot)
243+
if(options.hotOnly)
244+
devClient.push("webpack/hot/only-dev-server");
245+
else if(options.hot)
235246
devClient.push("webpack/hot/dev-server");
247+
236248
[].concat(wpOpt).forEach(function(wpOpt) {
237249
if(typeof wpOpt.entry === "object" && !Array.isArray(wpOpt.entry)) {
238250
Object.keys(wpOpt.entry).forEach(function(key) {

lib/Server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function Server(compiler, options) {
1919
throw new Error("'filename' option must be set in lazy mode.");
2020
}
2121

22-
this.hot = options.hot;
22+
this.hot = options.hot || options.hotOnly;
2323
this.headers = options.headers;
2424
this.sockets = [];
2525

0 commit comments

Comments
 (0)