Angular 4 - Import JS file with global variables?

1

I'm working with Angular 4 and my problem is this:

At the moment of generating a production package with ng build --prod my dist folder is generated and inside it my assets folder where I included a JS file called "ip.config.js". In this file I have two variables with the IPs that the client will use to consume RESTful from its local database.

This file "ip.config.js" I need to constantly update it with the IP that each client has on its server. But when generating my dist for production the variables are left with the value they had assigned at that time.

The question is: Can I configure my "ip.config.js" in some way that the variables in this file can be modified directly in the dist folder and not have to generate a distribution for each client?.

Best regards!

    
asked by Carlos Zepeda 21.08.2017 в 19:56
source

1 answer

0

Option 1

  

HTTP request instead of storing the data in a file.

Option 2

  

Use environment variables for each distribution.

    
answered by 23.08.2017 в 00:21