Jackthomson
Jackthomson

Reputation: 644

How to use Node Environment Variables inside Gulp?

When developing an application I use gulp as my build tool. When I deploy I use Heroku which fires up my node server and sets an environment variable of production. Same when I set gulp to set a variable of development. My question is how can I use this node variable inside my angular application? I did try gulp-constants but that wont work when it is being deployed as gulp is never run when deployed only my node server.

Upvotes: 0

Views: 297

Answers (1)

Tomer
Tomer

Reputation: 17940

You are confusing some terms:

  1. Gulp is a build tool, it only runs at build time (compile, concat, minify) and has nothing to do with run time.
  2. Angular is a client side framework, and as such, it has no access to the underlying system, so you can't get system variables using angular
  3. node is the server, and it does have access to system variables, so all you need to do is make an ajax request from angular to node, and have node give you the variables you need.

Upvotes: 1

Related Questions