Set new Global ENV
DarkDrim opened this issue · comments
Global.env param
Hello! How can I add an additional parameter to global.env ?
There are four modes of operation: dev (local), testing, productrion, and demo.
How can I add a "demo"?
I run: gulp build --env=demo
But it does not work.
PS I want in file main.ts present variable "declare var ENV: string" // demo
env for gulp tasks should be using --env=demo
but for usage in app, it's in
https://github.com/antonybudianto/angular2-starter/blob/master/src/systemjs.conf.js#L9
and you can override it before that file loaded
I rungulp serve-dev --env=demo
or gulp build --env=demo
But in systemjs.conf file global.ENV == undefined
no, --env=demo will never affect global.ENV (vice versa) since they're totally different.
--env is for node environment, global.ENV is for browser environment,
and browser environment should not be available in production build
Yes, how i can change global.ENV?
I want add "global.ENV = demo". How I can do this?
you can declare that anywhere before systemjs.conf.js loaded, for example you create env.js with following lines:
(function(global){
global.ENV = 'demo';
})(window);
and load the script before systemjs.conf.js
I have a different configuration files (a class).
I depending on the environment variable must use different files.
For example, "demo.conf" or "dev.conf"
Thank you, it solved my problem.