0

I have an angular application which runs in 3 different environment- Development, Staging and Production. Heroku builds the application based on my build script. I have a Gruntfile which as release task which uglifies the code.

Heroku runs this command Grunt release for both staging and production environment.

But I need logs to be enabled in staging and disabled in production environment.

For doing this, I tried accessing process.env.NODE_ENV in my grunt file. But it says process.env.NODE_ENV is undefined.

I am using webstorm to start the server in which I have defined process.env.NODE_ENV to production. But I am unable to access this in Grunt file.

Kindly let me know how to proceed.

Pramod
  • 41
  • 1
  • 7

2 Answers2

0

If you add some code at the bebening of your app? Like

var debug = true;

You can achieve this with banner/footer or putting a intro file when concatenating your files like here I'm trying out Grunt and need a simple way to concatenate my modules

Community
  • 1
  • 1
romuleald
  • 1,406
  • 16
  • 31
0

Heroku has its own way of handling config/environment variables, and also deliberately leaves NODE_ENV unset.

Run heroku config:set NODE_ENV=production in the working directory of your project to have that available in your build when you deploy. Any environment variable you set should be available on process.env.

max
  • 5,979
  • 2
  • 21
  • 16