When trying to change the host in webpack-dev-server from 0.0.0.0
to localhost
.
I looked in the code (bin/web-pack-dev-server
generated for Rails 5.1.3), tried to understand it, and noticed what I thought was a --host
parameter
PORT=8080 bin/webpack-dev-server --host=localhost
the --host=localhost
flag won't work.
From bin/web-pack-dev-server
:
begin
dev_server = YAML.load_file(CONFIG_FILE)["development"]["dev_server"]
DEV_SERVER_HOST = "http#{"s" if args('--https') || dev_server["https"]}://#{args('--host') || dev_server["host"]}:#{args('--port') || dev_server["port"]}"
puts DEV_SERVER_HOST
rescue Errno::ENOENT, NoMethodError
puts "Webpack dev_server configuration not found in #{CONFIG_FILE}."
puts "Please run bundle exec rails webpacker:install to install webpacker"
exit!
end
Changed PORT=8080 bin/webpack-dev-server --host=localhost
to PORT=8080 bin/webpack-dev-server --host localhost
Simply removing the =
fixed it.