Summary of methods for packaging Vue projects by environment
This article introduces to you a summary of the methods of packaging Vue projects by environment. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
When we develop projects, we use vue-cli 2.x version to create new projects. There are only two development environments: dev and pro. Sometimes we need a test environment for testing, so we have found many methods. Summary Here is the simplest method for everyone to use
1. package.json
Add a test running command under build
2. prod.env.js
Modify the code in config -> prod.env.js
'use strict' // 读取系统运行时候的变量 const target = process.env.npm_lifecycle_event; // 控制台日志输出 console.log('env is deploying, current env is', target) // 判断环境变量,是test,还是build if (target == 'test') { var obj = { NODE_ENV: '"production"', API_ROOT: '"此处替换为测试环境地址"', } } else { var obj = { NODE_ENV: '"production"', API_ROOT: '"此处替换为测试环境地址"', } } module.exports = obj;
3. Test environment:
$ npm run test
正式环境: " $ npm run build "
Recommended related articles:
What is the implementation principle of v-model? Introduction to the use of v-model (with code)
Detailed explanation of how to prevent bubbling by events in vueThe above is the detailed content of Summary of methods for packaging Vue projects by environment. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Vue.js is suitable for small and medium-sized projects and fast iterations, while React is suitable for large and complex applications. 1) Vue.js is easy to use and is suitable for situations where the team is insufficient or the project scale is small. 2) React has a richer ecosystem and is suitable for projects with high performance and complex functional needs.

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

React combines JSX and HTML to improve user experience. 1) JSX embeds HTML to make development more intuitive. 2) The virtual DOM mechanism optimizes performance and reduces DOM operations. 3) Component-based management UI to improve maintainability. 4) State management and event processing enhance interactivity.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

H5referstoHTML5,apivotaltechnologyinwebdevelopment.1)HTML5introducesnewelementsandAPIsforrich,dynamicwebapplications.2)Itsupportsmultimediawithoutplugins,enhancinguserexperienceacrossdevices.3)SemanticelementsimprovecontentstructureandSEO.4)H5'srespo

"h5" and "HTML5" are the same in most cases, but they may have different meanings in certain specific scenarios. 1. "HTML5" is a W3C-defined standard that contains new tags and APIs. 2. "h5" is usually the abbreviation of HTML5, but in mobile development, it may refer to a framework based on HTML5. Understanding these differences helps to use these terms accurately in your project.

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.
