如何通过环境设置奥雷利亚常数 [英] How to set a constant in aurelia by environment

查看:92
本文介绍了如何通过环境设置奥雷利亚常数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的API的基本URL从dev更改为prod.在Angular I中,用户使用config.json文件,该文件随后使用grunt-env

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 app using grunt-env

推荐答案

如果使用 Aurelia CLI ,它将在您的aurelia_project内部生成一个environments目录.

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

在此目录中,您可以设置环境配置,这些环境配置将根据传递给au build/run命令的--env [dev/stage/prod]标志复制到src目录中的environment.js中.

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.

然后,您可以使用import environment from './environment'访问您的环境特定的配置值.

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

您可以查看的另一个选项是 Aurelia配置插件,它也具有动态环境配置.

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

这篇关于如何通过环境设置奥雷利亚常数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆