Skip to content

Commit

Permalink
fix: 拼写
Browse files Browse the repository at this point in the history
  • Loading branch information
strommmm committed Apr 15, 2024
1 parent 72c0b20 commit bd3df96
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/bundler-webpack/src/config/definePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const prefixRE = /^UMI_APP_/;
const ENV_SHOULD_PASS = ['NODE_ENV', 'HMR', 'SOCKET_SERVER', 'ERROR_OVERLAY'];
const SOCKET_IGNORE_HOSTS = ['0.0.0.0', '127.0.0.1', 'localhost'];
// 环境变量传递自定义逻辑,默认直接透传
const EVN_GETTER: Record<string, (opts: IOpts) => string | undefined> = {
const CUSTOM_ENV_GETTER: Record<string, (opts: IOpts) => string | undefined> = {
SOCKET_SERVER: (opts: IOpts) => {
const { userConfig, host, port } = opts;
const socketServer = process.env.SOCKET_SERVER;
Expand All @@ -40,7 +40,9 @@ export function resolveDefine(opts: IOpts) {
ENV_SHOULD_PASS.concat(
Object.keys(process.env).filter((k) => prefixRE.test(k)),
).forEach((key: string) => {
const envValue = EVN_GETTER[key] ? EVN_GETTER[key](opts) : process.env[key];
const envValue = CUSTOM_ENV_GETTER[key]
? CUSTOM_ENV_GETTER[key](opts)
: process.env[key];
if (typeof envValue === 'undefined') {
return;
}
Expand Down

0 comments on commit bd3df96

Please sign in to comment.