webpack: Fix Hot Module Reloading in webpack.

This commit fixes hot module replacement in webpack. To do this
we open port 9994 used by webpack to communicate between browser
and devserver. The attempts to forward the proxy from 9991 failed
so the last resort was to open up the webpack port.
It also removes an uncessary plugin in the webpack config and moves
the --hot flag to tools/webpack.
This commit is contained in:
Armaan Ahluwalia 2018-04-26 00:46:08 +05:30 committed by Tim Abbott
parent bda9f3e3ea
commit f20671a509
3 changed files with 15 additions and 10 deletions

1
Vagrantfile vendored
View File

@ -121,6 +121,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end
config.vm.network "forwarded_port", guest: 9991, host: host_port, host_ip: host_ip_addr
config.vm.network "forwarded_port", guest: 9994, host: host_port + 3, host_ip: host_ip_addr
# Specify LXC provider before VirtualBox provider so it's preferred.
config.vm.provider "lxc" do |lxc|
if command? "lxc-ls"

View File

@ -29,7 +29,16 @@ 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]
webpack_args += [
'--config',
'tools/webpack.config.ts',
'--host', host,
'--port', port,
# We add the hot flag using the cli because it takes care
# of addition to entry points and adding the plugin
# automatically
'--hot'
]
if minify:
webpack_args.append('--optimize-minimize')
if disable_host_check:

View File

@ -91,21 +91,16 @@ export default (env?: string) : webpack.Configuration => {
new BundleTracker({filename: 'var/webpack-stats-dev.json'}),
// Better logging from console for hot reload
new webpack.NamedModulesPlugin(),
// Hot Reload of code in development
new webpack.HotModuleReplacementPlugin(),
// script-loader should load sourceURL in dev
new webpack.LoaderOptionsPlugin({debug: true}),
];
config.devServer = {
clientLogLevel: "warning",
hot: true,
inline: false,
stats: "minimal",
clientLogLevel: "error",
stats: "errors-only",
watchOptions: {
aggregateTimeout: 100,
poll: 100,
},
poll: 100
}
};
}
return config;