-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
feat: patch dotenv file parse #14116
base: 3.x
Are you sure you want to change the base?
Conversation
|
@@ -59,7 +59,7 @@ export default class CLI { | |||
} | |||
const mode = args.mode || process.env.NODE_ENV | |||
// 这里解析 dotenv 以便于 config 解析时能获取 dotenv 配置信息 | |||
const expandEnv = dotenvParse(appPath, args.envPrefix, mode) | |||
const expandEnv = dotenvParse(appPath, args as unknown as Parameters<typeof dotenvParse>[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mode
默认值还是要的, 函数里面可以不用加 if mode 的判断
我梳理了一下,之前的优先级(优先级从上到下代表从高到低): 如果除了
使用难度瞬间拔高,上述列的最后六行的优先级,我列出来了但是感觉似乎还是有点顺序问题... 思路一我的建议是按文件夹分组,
这样设计一目了然. 思路二:当检测到
当编译微信小程序时, 则只读取文件名
和以前优先级一样, 只是多了个 |
嗯, 加了 平台 配置文件就会成倍增加,分文件夹其实不能解决这个问题,但是可能更清晰;第二种方案的问题是 公共 常量配置 没法维护。我想想 |
@bigmeow 把配置文件 都放到 env 文件夹下面, 这样内部再分 平台,文件的 优先级顺序都是同样的, 只是指定平台的 配置文件 优先级,比未指定平台的配置文件优先级高。这样 env 外层的配置文件 可以写 公共配置,平台自己的写在自己的文件夹里; |
|
这个 PR 做了什么? (简要描述所做更改)
调整 dotenv 文件解析逻辑,支持 根据打包平台 读取配置文件
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台: