试图更改webpack-dev-server主机

时间:2017-10-13 16:04:48

标签: ruby-on-rails webpack webpack-dev-server react-rails webpacker

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

1 个答案:

答案 0 :(得分:0)

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

只需删除=修复它。