1

当尝试将 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
4

1 回答 1

1

改为PORT=8080 bin/webpack-dev-server --host=localhost_PORT=8080 bin/webpack-dev-server --host localhost

只需删除=固定它。

于 2017-10-13T17:48:40.190 回答