Can I use file ? Please :/

Hey Is it possible to use the file to store variables ?
I’m not sure how I will be able to do it , but it makes sense to have it there.
e.g. this in
DEV_URL = 'foo/api/v1/test';

DEV_URL = 'foo/api/v1/production';

and how can this be referenced on other pages/providers ?

I solved such a question like following:

I created my own class resources.ts which export following:

export class Resources {

   static get Constants():any {
       return {
        API: {
            DEV_URL = 'foo/api/v1/test';


which you could use


To switch between TEST_URL and PROD_URL I have then write a gulp task to switch between these (like “gulp prod” and “gulp test”)

Of course it need a little bit of attention to be sure to never validate in my repository my class with the test URL…but otherwise that made the trick for me.

Hey @reedrichards , great idea :slight_smile: ,
I’m just a little disappointed that there is no documentation on using and

Maybe there is something side angular2?
Anyway glad to hear you like the idea

About gulp, I use:

npm install --save-dev replace

and something like

var replaceFilesTargetServer = ['./src/providers/resources.ts'];

gulp.task('test', function () {
  return replace({
    regex: "https://produrl",
    replacement: "http://devurl",
    paths: replaceFilesTargetServer,
    recursive: false,
    silent: false
1 Like