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 

回答

0

改變PORT=8080 bin/webpack-dev-server --host=localhostPORT=8080 bin/webpack-dev-server --host localhost

只需去除=固定它。