mirror of https://github.com/zulip/zulip.git
webpack: Disable host check for webpack-dev-server.
Webpack dev server by default does host checking for requests. so in dev enviorment if the the request came for zulipdev.com it would not send js files which caused dev envoirment to not work.
This commit is contained in:
parent
62fb139af7
commit
bc454bab88
|
@ -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:
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue