lib/shakapacker/dev_server_runner.rb in shakapacker-7.1.0 vs lib/shakapacker/dev_server_runner.rb in shakapacker-7.2.0.rc.0

- old
+ new

@@ -66,15 +66,11 @@ env = Shakapacker::Compiler.env env["SHAKAPACKER_CONFIG"] = @shakapacker_config env["WEBPACK_SERVE"] = "true" env["NODE_OPTIONS"] = ENV["NODE_OPTIONS"] || "" - cmd = if node_modules_bin_exist? - ["#{@node_modules_bin_path}/webpack", "serve"] - else - ["yarn", "webpack", "serve"] - end + cmd = build_cmd if @argv.include?("--debug-webpacker") Shakapacker.puts_deprecation_message( Shakapacker.short_deprecation_message( "--debug-webpacker", @@ -94,9 +90,19 @@ cmd += @argv Dir.chdir(@app_path) do Kernel.exec env, *cmd end + end + + def build_cmd + if Shakapacker::Utils::Misc.use_package_json_gem + return package_json.manager.native_exec_command("webpack", ["serve"]) + end + + return ["#{@node_modules_bin_path}/webpack", "serve"] if node_modules_bin_exist? + + ["yarn", "webpack", "serve"] end def node_modules_bin_exist? File.exist?("#{@node_modules_bin_path}/webpack-dev-server") end