如何在 vue.js 中创建多个 .env

How to create multiple .env in vue.js(如何在 vue.js 中创建多个 .env)

本文介绍了如何在 vue.js 中创建多个 .env的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被困在 vue.js 中,如何管理多个服务器的多个环境,如本地、开发和生产?

I am stuck in vue.js, how to manage multiple env for multiple servers like local, development and production ?

推荐答案

你可以为不同的环境创建不同的 .env 文件,比如.env.development.env.staging.env.production 并在你的 package.json 中创建这样的构建脚本 -

you can create different .env file for different environment like .env.development, .env.staging, and .env.production and in your package.json create build script like this -

"scripts": {
"build-dev": "vue-cli-service build --mode development --modern",
"build-stage": "vue-cli-service build --mode staging --modern",
"build-prod": "vue-cli-service build --mode production --modern",
}

有关详细信息,请遵循此文档 https://cli.vuejs.org/guide/mode-and-env.html

For details please follow this doc https://cli.vuejs.org/guide/mode-and-env.html

这篇关于如何在 vue.js 中创建多个 .env的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何在 vue.js 中创建多个 .env

基础教程推荐