- Upload and replace all environment variables from your
.env
file to vercel
pnpm i -D nx-vercel-utils
This plugin adds a env
executor that will deploy your environment variables to vercel.
- You will need to have the vercel cli installed. Either globally or locally in your project. If you install it globally you have to set
packageManager
option toglobal
.
pnpm i -D vercel
You also need to cd into the project and run vercel link
to link your project to your vercel account. That will create a .vercel folder.
Example
cd apps/frontend
vercel login # if you haven't logged in
vercel link
See the example here
...
"targets": {
"deploy-vercel-env": {
"executor": "../dist:env",
"options": {
"flavors": {
"development": "development",
"production": "production",
"staging": "staging"
},
"vercelProjectName": "your-vercel-project-name"
}
},
You need to create .env.{flavor} files for each flavor you want to deploy. The flavor name will be the key in the flavors
object.
Option | Description | Default | Alias |
---|---|---|---|
vercelProjectName |
The name of the vercel project. | required | project |
flavors |
A object of the flavors to use, the key is the flavor name and value is either 'production', 'development', 'preview' or 'preview:{branch}'. Read more here | required | |
flavor |
The flavor to use, default will be the first key in the flavors object. |
||
silent |
Whether to suppress all logs. | false |
s |
verbose |
Whether to run the command with verbose logging. | false |
v |
packageManager |
The package manager to use for deploying with firebase-tools. Either: pnpm , npm , yarn or global . |
||
concurrency |
The number of environments to deploy in parallel | 10 | c |
pnpm nx deploy-vercel-env frontend
# will deploy the environment variables for the first flavor in the flavors object
pnpm nx deploy-vercel-env frontend --flavor staging