diff --git a/packages/bundler-webpack/src/config/definePlugin.ts b/packages/bundler-webpack/src/config/definePlugin.ts index 1db98e005dec..3c7f4c8bcd07 100644 --- a/packages/bundler-webpack/src/config/definePlugin.ts +++ b/packages/bundler-webpack/src/config/definePlugin.ts @@ -25,7 +25,8 @@ export function resolveDefine(opts: { define: any; publicPath?: string }) { env.PUBLIC_PATH = opts.publicPath || '/'; for (const key in env) { - env[key] = JSON.stringify(env[key]); + env[`process.env.${key}`] = JSON.stringify(env[key]); + delete env[key]; } const define: Record = {}; @@ -36,7 +37,7 @@ export function resolveDefine(opts: { define: any; publicPath?: string }) { } return { - 'process.env': env, + ...env, ...define, }; }