Skip to content

How to pass environment variables?

Roy Bao edited this page Mar 21, 2016 · 7 revisions

In both webpack.config.js and webpack.prod.config.js:

new webpack.DefinePlugin({
  'process.env': {
    'API_URL': JSON.stringify(process.env.API_URL)
  }
})

Then you can just use it in the code

this._http.get(process.env.API_URL, options);

For development I use dotenv to set the environment variable. For production just set environment variable as usual.

Clone this wiki locally