diff --git a/tools/run-dev.py b/tools/run-dev.py index 0924514a59..c25ddf4ead 100755 --- a/tools/run-dev.py +++ b/tools/run-dev.py @@ -166,6 +166,10 @@ else: webpack_cmd = ['./tools/webpack', '--watch', '--port', str(webpack_port)] if options.minify: webpack_cmd.append('--minify') + if options.interface is None: + # If interface is None and we're listening on all ports, we also need + # to disable the webpack host check so that webpack will serve assets. + webpack_cmd.append('--disable-host-check') if options.interface: webpack_cmd += ["--host", options.interface] else: diff --git a/tools/webpack b/tools/webpack index 7ff85cb40c..44ecbd598a 100755 --- a/tools/webpack +++ b/tools/webpack @@ -25,13 +25,15 @@ def run(): ['--config', 'tools/webpack.config.ts', '-p'] + ['--env', 'production']) -def run_watch(host, port, minify): - # type: (str, str, bool) -> None +def run_watch(host, port, minify, disable_host_check): + # type: (str, str, bool, bool) -> None """watches and rebuilds on changes, serving files from memory via webpack-dev-server""" webpack_args = ['node', 'node_modules/.bin/webpack-dev-server'] webpack_args += ['--config', 'tools/webpack.config.ts', '--port', port, "--host", host] if minify: webpack_args.append('--optimize-minimize') + if disable_host_check: + webpack_args.append('--disable-host-check') subprocess.Popen(webpack_args) def run_test(): @@ -72,11 +74,14 @@ parser.add_argument('--port', parser.add_argument('--minify', action='store_true', dest='minify', default=False, help='Minify and optimize the assets (for development)') +parser.add_argument('--disable-host-check', + action='store_true', dest='disable_host_check', default=None, + help='Disable host check for webpack-dev-server') args = parser.parse_args() if args.test: run_test() elif args.watch: - run_watch(args.host, args.port, args.minify) + run_watch(args.host, args.port, args.minify, args.disable_host_check) else: run()