罗广辉
2025-11-15 fac27acb9b453cfe9f66fdc4ef510d0c615d1e8f
vite.config.js
@@ -12,15 +12,19 @@
  const { UNI_PLATFORM,UNI_CUSTOM_DEFINE } = process.env
  const ENV_NAME = UNI_CUSTOM_DEFINE && JSON.parse(UNI_CUSTOM_DEFINE)?.ENV_NAME
  console.log("平台 -> ", UNI_PLATFORM) // 得到 mp-weixin, h5, app 等
  console.log("环境 -> ", ENV_NAME || 'development') // 得到 development,test 等
  const __APP_ENV__ = {
    UNI_PLATFORM: UNI_PLATFORM,
    ENV_NAME: ENV_NAME || 'development'
  }
  console.log("平台 -> ", __APP_ENV__.UNI_PLATFORM) // 得到 mp-weixin, h5, app 等
  console.log("环境 -> ", __APP_ENV__.ENV_NAME) // 得到 development,test 等
  const env = loadEnv(mode, fileURLToPath(new URL("./env", import.meta.url)))
  // console.log("环境变量 env -> ", env)
  const isBuild = process.env.NODE_ENV === "production"
  return {
    define: {
      __APP_ENV__: process.env,
      __APP_ENV__,
    },
    // 自定义env目录
    envDir: "./env",
@@ -37,7 +41,7 @@
      hmr: true,
      host: true,
      open: true,
      proxy: createViteProxy(env,ENV_NAME)
      proxy: createViteProxy(env,__APP_ENV__.ENV_NAME)
    },
    // 设置scss的api类型为modern-compiler
    css: {