Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow NODE_ENV to be overridden in webpacker:compile task #2020

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/tasks/webpacker/compile.rake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,18 @@ end
namespace :webpacker do
desc "Compile JavaScript packs using webpack for production with digests"
task compile: ["webpacker:verify_install", :environment] do
Webpacker.with_node_env("production") do
node_env = "production"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node_env = ENV["NODE_ENV"] || "production"

if node_env != "production"
  $stdout.puts "Using NODE_ENV=#{ENV["NODE_ENV"]} from local "\
     "environment instead of default NODE_ENV=production"
end


if ENV.has_key?("NODE_ENV")
node_env = ENV["NODE_ENV"]

if node_env != "production"
$stdout.puts "Using NODE_ENV=#{ENV["NODE_ENV"]} from local "\
"environment instead of default NODE_ENV=production"
end
end

Webpacker.with_node_env(node_env) do
ensure_log_goes_to_stdout do
if Webpacker.compile
# Successful compilation!
Expand Down