尝试将webpack-dev-server中的主机从0.0.0.0
更改为localhost
。
我查看了为Rails 5.1.3生成的代码bin/web-pack-dev-server
,尝试了解它,并注意到我认为是--host
参数
PORT=8080 bin/webpack-dev-server --host=localhost
--host=localhost
标志不起作用。
来自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
答案 0 :(得分:0)
将PORT=8080 bin/webpack-dev-server --host=localhost
更改为PORT=8080 bin/webpack-dev-server --host localhost
只需删除=
修复它。