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

Conversation

dbalatero
Copy link
Contributor

Closes #1558

Since users might have a default NODE_ENV=development set in their .envrc or .env file, I added a warning message letting them know that they were choosing a different NODE_ENV than the default production value. I think this will help avoid opaque compilation bugs.

@@ -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

@gauravtiwari
Copy link
Member

Fixed here: 4c79d22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compile is always using production env?
3 participants