How to set a constant in aurelia by environment

前端 未结 3 651
谎友^
谎友^ 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:50

    If you use the Aurelia CLI, it will generate an environments directory inside of your aurelia_project.

    Within this directory you can setup environmental configs that will be copied into environment.js in your src directory based the --env [dev/stage/prod] flag that you pass into your au build/run commands.

    Then you can use import environment from './environment' to access your environment specific configuration values.

    Another option that you can look into is the Aurelia Configuration Plugin, which also has dynamic environmental configs.

提交回复
热议问题