Tuesday, 4 April 2017

webpack typescript angular 2 settings based on environement

I have an angular service that needs to access 2 different url based on the npm environement but I cant figure out how to do this

lets say in dev (on my machine), I should have

    authenticate(login: string, pass: string): Observable < boolean > {
        return this.http.get('http://some_url')
            .map((response: Response) => response.json());
    };

on the production it should be

    authenticate(login: string, pass: string): Observable < boolean > {
        return this.http.get('http://some_other_url')
            .map((response: Response) => response.json());
    };

so I would like to set that url in the code depending on

process.env.npm_lifecycle_event

is it possible ? how to achieve that ?

thanks



via ninja

No comments:

Post a Comment