-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]无法配置自定义的环境变量 #7799
Comments
你可以创建两个和 文件内定义你不同环境下的process.env example: import { defineConfig } from "umi";
export default defineConfig({
define: {
"process.env": {
SOME_KEY: "value",
APP_COOKIE_TOKEN: 123456,
},
},
}); 之后修改你的package.json命令
当然, dev, prod名称是可以替换的 |
@jk4235 为什么不能直接使用process.env 需要在define里设置呢 |
umi中的环境变量列表只有这些 想要自定义的环境变量, 这是我找到的一个workaround方法 而且可以保持类型,而不是都是字符串 |
设置一个环境变量真是麻烦,绕来绕去的,搞的我花了一个多小时才搞明白,真是烦躁,直接通过coss-env设置自己想要的环境变量和值有那么难吗,谁搞的现在的这种设计,拉出来打一顿算了。 |
深有体会,这个玩意真是好麻烦啊,环境变量本身很简单的东西弄的这么麻烦,弄了好久也不生效,可以组团打他一顿。 |
最新简洁用法,直接在 |
有效,这个设计相当奇怪。。。 |
umi4 怎么设置 |
What happens?
配置的环境变量没有生效
控制台中无法打印出 自定义的环境变量
Mini Showcase Repository(REQUIRED)
How To Reproduce
Steps to reproduce the behavior: 1. 2.
Expected behavior 1. 2.
Context
The text was updated successfully, but these errors were encountered: