forked from PatrickJS/angular-webpack-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
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.
enjoy — AngularClass
Learn AngularJS, Angular 2, and Modern Web Development from the best. Looking for corporate Angular training, want to host us, or Angular consulting? patrick@angularclass.com
