Skip to content

Commit f56f8ad

Browse files
authored
Dev server detection workaround (correct PR) (#2898)
1 parent cdc31c0 commit f56f8ad

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/webpacker/dev_server_runner.rb

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def detect_port!
6464
def execute_cmd
6565
env = Webpacker::Compiler.env
6666
env["WEBPACKER_CONFIG"] = @webpacker_config
67+
env["WEBPACK_DEV_SERVER"] = "true"
6768

6869
cmd = if node_modules_bin_exist?
6970
["#{@node_modules_bin_path}/webpack", "serve"]

test/dev_server_runner_test.rb

+10-2
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,27 @@ def dev_server.https?; true; end
4343
end
4444
end
4545

46+
def test_environment_variables
47+
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/development.js"]
48+
env = Webpacker::Compiler.env.dup
49+
env["WEBPACKER_CONFIG"] = "#{test_app_path}/config/webpacker.yml"
50+
env["WEBPACK_DEV_SERVER"] = "true"
51+
verify_command(cmd, env: env)
52+
end
53+
4654
private
4755
def test_app_path
4856
File.expand_path("test_app", __dir__)
4957
end
5058

51-
def verify_command(cmd, use_node_modules: true, argv: [])
59+
def verify_command(cmd, use_node_modules: true, argv: [], env: Webpacker::Compiler.env)
5260
cwd = Dir.pwd
5361
Dir.chdir(test_app_path)
5462

5563
klass = Webpacker::DevServerRunner
5664
instance = klass.new(argv)
5765
mock = Minitest::Mock.new
58-
mock.expect(:call, nil, [Webpacker::Compiler.env, *cmd])
66+
mock.expect(:call, nil, [env, *cmd])
5967

6068
klass.stub(:new, instance) do
6169
instance.stub(:node_modules_bin_exist?, use_node_modules) do

0 commit comments

Comments
 (0)