How to set a constant in aurelia by environment

前端 未结 3 648
谎友^
谎友^ 2021-01-17 15:06

I\'d like my API\'s base URL to change from dev to prod. In Angular I user to use a config.json file which was later injected into the

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-17 15:51

    If you want to 'inject' it only once then what is stopping you from using a simple ES6 module ? It should be loaded only once from the server.

    For instance you could something like that in a config.js file : (warning ! I didn't try to run it)

    export var Config = {
        path : 'path to find'
    };
    

    you can then use your module anywhere you need it :

    import {Config} from 'config';
    

提交回复
热议问题