In the development of my Nuxt application, I am faced with the task of setting up two distinct environments - staging and production. Besides these, the local environment is also considered as staging. As part of this setup, I need to create specific commands to generate builds for each environment, which will then be deployed on separate servers.
In essence, I have two main queries:
- The issue I am encountering involves the following command:
npm run generate
Typically, this command always generates a production build. To address this, I checked the environment using:
console.log(process.env.NODE_ENV)
My question here is how can I generate a new build where the environment would be set to something like "staging"?
- Another aspect that I'm grappling with pertains to creating
.env
files to store environment-specific variables. Specifically, I'm confused about how to manage multiple env files for the different environments (i.e., staging and production).
I realize that these inquiries are research-oriented, and despite spending days scouring the internet, relevant information has proven elusive or unclear. If anyone could kindly direct me towards the correct resources or solutions, it would be greatly appreciated.