Skip to content

createNativeShellViteConfig

业务包 Vite:Web / Capacitor native 模式共用的 env 合并、相对 base、产品名注入。

函数签名

typescript
function resolveSpaNativeShellVite(
  options: ResolveSpaNativeShellViteOptions,
): SpaNativeShellViteResolved

前置依赖

参数名类型说明
loadEnvVite loadEnv由业务包传入,shared 不依赖 vite 包
profileEnvKeystringHOME_VITE_PROFILEdev 时叠 .env.dev
shellManifestJsonstringshell.manifest.json 文本

返回值

base(壳构建为 ./)、defineVITE_NATIVE_SHELL / 产品名 / 版本)、htmlPlugin<title>

工作原理

  1. mode === nativemergeProfileViteEnv,按 profile 叠 .env.prod.env.dev
  2. 其它 mode 直接 loadEnv(mode)
  3. 壳构建强制相对路径,避免 capacitor:// / https://localhost 下绝对 COS base 失效。