Skip to content

Commit e1983bc

Browse files
committed
bug #529 Honor --public flag given to 'yarn run dev-server ...' (lyrixx, Lyrkan)
This PR was merged into the master branch. Discussion ---------- Honor --public flag given to 'yarn run dev-server ...' I'm using docker (one container for the front, another one for webpack) and I had to do this PR to make it work. For reference, this is the command I (docker actually) executed ``` yarn run dev-server --host 0.0.0.0 --port 9999 --hot --public https://example.com:443 --disable-host-check ``` Commits ------- 5fb19de Update lib/config/parse-runtime.js 4275ff0 Honor --public flag given to 'yarn run dev-server ...'
2 parents e8e2359 + 5fb19de commit e1983bc

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lib/config/parse-runtime.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,19 @@ module.exports = function(argv, cwd) {
4949
runtimeConfig.useHotModuleReplacement = argv.hot || false;
5050
runtimeConfig.devServerKeepPublicPath = argv.keepPublicPath || false;
5151

52-
var host = argv.host ? argv.host : 'localhost';
53-
var port = argv.port ? argv.port : '8080';
54-
runtimeConfig.devServerUrl = `http${runtimeConfig.devServerHttps ? 's' : ''}://${host}:${port}/`;
52+
if (typeof argv.public === 'string') {
53+
if (argv.public.includes('://')) {
54+
runtimeConfig.devServerUrl = argv.public;
55+
} else if (runtimeConfig.devServerHttps) {
56+
runtimeConfig.devServerUrl = `https://${argv.public}`;
57+
} else {
58+
runtimeConfig.devServerUrl = `http://${argv.public}`;
59+
}
60+
} else {
61+
var host = argv.host ? argv.host : 'localhost';
62+
var port = argv.port ? argv.port : '8080';
63+
runtimeConfig.devServerUrl = `http${runtimeConfig.devServerHttps ? 's' : ''}://${host}:${port}/`;
64+
}
5565

5666
break;
5767
}

0 commit comments

Comments
 (0)