angularjs - Server settings in modern JavaScript apps -


i'm looking solution have server settings in config file of sort separate js app (which running in dev or prod (built) mode) allow server replace file new 1 @ random point in time (when settings have changed) , allow js app pick , refresh it's settings.

this setting urls api endpoints.

my choice of js framework angular 1 , 4 answers geared towards various js frameworks/libraries applicable.

to have server settings in config file of sort separate js app

if thinking having server settings exposed front gonna have bad time ;)

i assume think keep api urls , maybe config along in separate file while develop. can advise 2 approaches:

1.) simple - have single js file single object necessary api urls , settings in tree structure organisational purposes. have dev, test , production property in them. once load app 1st thing should app load correct settings. fast , doesn't require additional knowledge. everywhere had configurable hard coded replace variable derives file. should suffice simple applications.

2.) powerfull - bigger applications loads of different dependencies , more formal , professional approach people do, use nodejs, leverage grunt or gulp version dependencies , write scripts different builds. requires install , learn use new stuff offers way more power.

even better combine 2 approaches, link external dependencies dynamically build , internal via including correct js file api information.

you can use other npm modules assist development precompiling css, lint code, rearrange , organise files types folders, auto-name files or folders.

basically, of repetitive tasks while developing can automated way. shines on bigger projects when handled proficient , experienced 2nd approach, can save months of repetitive tasks across team.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -