提交 6ebe85ed 编写于 作者: fxy060608's avatar fxy060608

fix(x-android): env

上级 1a3231c6
...@@ -40,7 +40,7 @@ import { ...@@ -40,7 +40,7 @@ import {
import { genClassName } from '../..' import { genClassName } from '../..'
import type { ResolvedConfig } from 'vite' import type { ResolvedConfig } from 'vite'
import { isString } from '@vue/shared' import { extend, isString } from '@vue/shared'
declare class WatchProgramHelper { declare class WatchProgramHelper {
watch(timeout?: number): void watch(timeout?: number): void
...@@ -386,13 +386,15 @@ function parseUniExtApiProviders( ...@@ -386,13 +386,15 @@ function parseUniExtApiProviders(
function parseProcessEnv(resolvedConfig: ResolvedConfig) { function parseProcessEnv(resolvedConfig: ResolvedConfig) {
const env: Record<string, unknown> = {} const env: Record<string, unknown> = {}
const defines = { const defines: Record<string, unknown> = {}
...resolvedConfig.define!, const userDefines = resolvedConfig.define!
...resolvedConfig.env, Object.keys(userDefines).forEach((key) => {
if (key.startsWith('process.env.')) {
defines[key.replace('process.env.', '')] = userDefines[key]
} }
})
extend(defines, resolvedConfig.env)
Object.keys(defines).forEach((key) => { Object.keys(defines).forEach((key) => {
if (key.startsWith('process.env.')) {
let value = defines[key] let value = defines[key]
if (isString(value)) { if (isString(value)) {
try { try {
...@@ -402,8 +404,7 @@ function parseProcessEnv(resolvedConfig: ResolvedConfig) { ...@@ -402,8 +404,7 @@ function parseProcessEnv(resolvedConfig: ResolvedConfig) {
if (!isString(value)) { if (!isString(value)) {
value = JSON.stringify(value) value = JSON.stringify(value)
} }
env[key.replace('process.env.', '')] = value env[key] = value
}
}) })
return env return env
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册