Skip to content

Commit

Permalink
Speed up bin/webpack* executables by dropping yarn run overhead (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
javan authored and dhh committed Aug 12, 2017
1 parent 68b9f08 commit 732a70c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
21 changes: 10 additions & 11 deletions lib/install/bin/webpack-dev-server.tt
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,19 @@ end
ARGV.delete(arg)
end

newenv = {
env = {
"NODE_PATH" => NODE_MODULES_PATH.shellescape,
"ASSET_HOST" => DEV_SERVER_ADDR.shellescape
}.freeze
}

options = ["--progress", "--color", "--config", WEBPACK_CONFIG, "--host", LISTEN_HOST_ADDR, "--public", "#{HOSTNAME}:#{PORT}", "--port", PORT.to_s]

if Gem.win_platform?
# Workaround for yarn not playing nicely with path separators
cmdline = ["#{NODE_MODULES_PATH}/.bin/webpack-dev-server", *options] + ARGV
else
cmdline = ["yarn", "run", "webpack-dev-server", "--", *options] + ARGV
end
cmd = [
"#{NODE_MODULES_PATH}/.bin/webpack-dev-server", "--progress", "--color",
"--config", WEBPACK_CONFIG,
"--host", LISTEN_HOST_ADDR,
"--public", "#{HOSTNAME}:#{PORT}",
"--port", PORT.to_s
] + ARGV

Dir.chdir(APP_PATH) do
exec newenv, *cmdline
exec env, *cmd
end
11 changes: 3 additions & 8 deletions lib/install/bin/webpack.tt
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@ unless File.exist?(WEBPACK_CONFIG)
exit!
end

newenv = { "NODE_PATH" => NODE_MODULES_PATH.shellescape }
if Gem.win_platform?
# Workaround for yarn not playing nicely with path separators
cmdline = ["#{NODE_MODULES_PATH}/.bin/webpack", "--config", WEBPACK_CONFIG] + ARGV
else
cmdline = ["yarn", "run", "webpack", "--", "--config", WEBPACK_CONFIG] + ARGV
end
env = { "NODE_PATH" => NODE_MODULES_PATH.shellescape }
cmd = [ "#{NODE_MODULES_PATH}/.bin/webpack", "--config", WEBPACK_CONFIG ] + ARGV

Dir.chdir(APP_PATH) do
exec newenv, *cmdline
exec env, *cmd
end

0 comments on commit 732a70c

Please sign in to comment.