尝试更改 webpack-dev-server 主机
Attempting to change webpack-dev-server host
尝试将 webpack-dev-server 中的主机从 0.0.0.0
更改为 localhost
时。
我查看了代码(bin/web-pack-dev-server
为 Rails 5.1.3 生成),试图理解它,并注意到我认为是 --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
已将 PORT=8080 bin/webpack-dev-server --host=localhost
更改为 PORT=8080 bin/webpack-dev-server --host localhost
只需删除 =
即可修复它。
尝试将 webpack-dev-server 中的主机从 0.0.0.0
更改为 localhost
时。
我查看了代码(bin/web-pack-dev-server
为 Rails 5.1.3 生成),试图理解它,并注意到我认为是 --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
已将 PORT=8080 bin/webpack-dev-server --host=localhost
更改为 PORT=8080 bin/webpack-dev-server --host localhost
只需删除 =
即可修复它。