-
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
docs: env file #12330
docs: env file #12330
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe update shifts the method of configuring environment variables in Umi projects. Instead of using separate Changes
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Files not reviewed due to errors (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
既然文档都放出去了,注意到之前有人提过类似的 issues?不如直接支持一下更好 🤔 import { existsSync, readFileSync } from 'fs';
import { join as PATH_join } from 'path';
import { parse } from '../../compiled/dotenv';
import { expand } from '../../compiled/dotenv-expand';
export function loadEnv(opts: { cwd: string; envFile: string }) {
const join = (...args: string[]) => PATH_join(opts.cwd, ...args);
const files = [
join(opts.envFile),
join(`${opts.envFile}.local`),
process.env.NODE_ENV && join(`${opts.envFile}.${process.env.NODE_ENV}`),
process.env.NODE_ENV && join(`${opts.envFile}.${process.env.NODE_ENV}.local`),
].filter(Boolean) as string[];
for (const file of files) {
if (!existsSync(file)) continue;
const parsed: Record<string, string> = parse(readFileSync(file)) || {};
expand({ parsed, ignoreProcessEnv: true });
for (const key of Object.keys(parsed)) {
process.env[key] = parsed[key];
}
}
} |
貌似我犯了一个错误,
.env.development
这种形式的环境变量是不支持的。Summary by CodeRabbit
.env.development
and.env.production
files to usingcross-env
in start commands or defining values in Umi configuration files.