1. IntroductionGenerally in our project development, there are usually the following three environments
2. Scenario Then there is a situation where we need to distinguish different
3. Create an environment Next, we create the module.exports = { test: { MODE: 'test' }, rc: { MODE: 'rc', }, prod: { MODE: 'prod', } } After configuring the corresponding environment, we add packaging commands to as follows: "build:test": "cross-env MODE=test nuxt build", "build:rc": "cross-env MODE=rc nuxt build", "build:prod": "cross-env MODE=prod nuxt build", 3.1 Injecting environment variables Open the const env = require('./env') module.exports = { env: { NUXT_ENV: env[process.env.MODE] } } 4. FinallyFinally, we use it in the page. The code is as follows: const api = { prod: 'http://ydhtml.com', test: 'http://test-ydhtml.com', rc: 'http://rc-ydhtml.com' } const baseURL = api[process.env.NUXT_ENV.MODE] This is the end of this article about nuxt.js multi-environment variable configuration. For more related nuxt.js multi-environment variable configuration content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: CSS animation property usage and example code (transition/transform/animation)
>>: Common HTML tag writing errors
Description of the situation: Today, I logged int...
Preface Currently, the front-end solves cross-dom...
Recently, I made a function similar to shake, usi...
This article deploys Jenkins+Maven+SVN+Tomcat thr...
Before hiding: After hiding: CSS: Copy code The co...
Today, there is such a requirement. If the logged...
Write to the css file Copy code The code is as fol...
The target attribute of a link determines where th...
Preface The origin is a question 1: If your umask...
Preface 1. Debounce: After a high-frequency event...
SMIL adds support for timing and media synchroniz...
Table of contents What is a skeleton screen How t...
Storage rules for varchar In versions below 4.0, ...
To execute a shell command in Docker, you need to...
Preface Everyone knows that many sites now charge...