After the development of the Vue project is completed, we need to package the project and launch it online. At the same time, we hope to preview the production environment project locally. (Take the project generated by vue-cli scaffolding as an example) 1. Transition from development environment to production environmentAfter the project development is completed, we first need to notify the backend to obtain an online path, and then switch the previous development path to the online path. Open the dev.env.js file in the config folder of the project and fill in the online path given by the backend. 'use strict' module.exports = { NODE_ENV: '"production"', BASE_API: '"http://sdk.*********.cn:3838/"' //Online path} 2. Set a unified request pathAfter the project is packaged, all js, css, and pictures will be in their own unified folders, so the previous path needs to be changed. A single modification takes too long, so what should be done? Open utils.js in the build folder and add it according to your needs. Usually two ../ will be added. if (options.extract) { return ExtractTextPlugin.extract({ use: loaders, fallback: 'vue-style-loader', publicPath : '../../' // Newly added content, path configuration}) } else { return ['vue-style-loader'].concat(loaders) } } In some cases, there will be a problem that the main path of HTML is not introduced correctly. At this time, we need to configure the index.js file inside the config folder and modify the assetsPublicPath. Note that the assetsPublicPath here is the assetsPublicPath path in the build production environment, not the assetsPublicPath in the dev development environment. 3. Run the packaging commandnpm run build //Generally, if it is not changed, it will be built The results after running are as follows: Generate a dist folder after running This concludes this article about the steps for packaging and releasing the Vue project online. For more relevant content on packaging and releasing the Vue project online, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: MySQL 8.0.24 installation and configuration method graphic tutorial
>>: Getting Started Tutorial on Animating SVG Path Strokes Using CSS3
1. Unzip the file to the current directory Comman...
Table of contents 01 JavaScript (abbreviated as: ...
Table of contents 1. Introduction to Nginx 2. Ima...
This article example shares the specific code of ...
Using the Vue language and element components, we...
What is HTML? HTML is a language used to describe...
MySQL Query Cache is on by default. To some exten...
This article example shares the specific code for...
After the form is submitted, the returned HTML pag...
Problem description: When phpstorm's SFTP hos...
Table of contents 1. context 1. Usage scenarios 2...
Table of contents 1. How to obtain elements Get i...
Preface In WEB development, we often involve cros...
Learning objectives: Learn to use Windows system ...
1. Download the mysql repo source $ wget http://r...