1
嘗試將webpack-dev-server中的主機從0.0.0.0
更改爲localhost
。嘗試更改webpack-dev-server主機
我看了代碼(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