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
This article installs Google Input Method. In fac...
1 Download MySQL8 from the official website and i...
Use self:: or __CLASS__ to get a static reference...
Preface As we all know, by default, the MySQL ins...
Table of contents 1. Introduction 2. Principle II...
Everything is a file! UNIX has already said it. E...
Table of contents 1. Introduction to NFS-Ganesha ...
Table of contents 1. Installation 2.APi 3. react-...
In more and more websites, the use of XHTML is rep...
When I was writing join table queries before, I a...
Let me first explain why the text is not vertical...
Chatbots can save a lot of manual work and can be...
Table of contents Business requirements: Solution...
This article describes how to add or expand a dis...
Object's hasOwnProperty() method returns a Bo...