There are three main ways to configure environment variables in uni-app project:

# vue-config.js

The webpack configuration can be modified in vue.config.js, including environment variables. For details, please refer to vue-config.js.

# package.json

When customizing the conditional compilation platform, you can configure environment variables under the env node of the package.json file. For details, please refer to package.json

# .env

CLI 创建的项目中可以在根目录中放置 .env 文件来指定环境变量,具体参考:Vue2Vue3

# 注意

  • uni-app x不支持自定义环境变量。