Steps to package and release the Vue project

Steps to package and release the Vue project

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 environment

After 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 path

After 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 command

npm 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:
  • A graphic tutorial on how to package and launch a Vue.js project
  • A brief discussion on Vue automated deployment and packaging
  • An example of how to package and launch vue-cli
  • The whole process of vue.js project packaging and launch

<<:  MySQL 8.0.24 installation and configuration method graphic tutorial

>>:  Getting Started Tutorial on Animating SVG Path Strokes Using CSS3

Recommend

Super detailed basic JavaScript syntax rules

Table of contents 01 JavaScript (abbreviated as: ...

Implementation of Nginx configuration of local image server

Table of contents 1. Introduction to Nginx 2. Ima...

JavaScript canvas text clock

This article example shares the specific code of ...

Vue uses monaco to achieve code highlighting

Using the Vue language and element components, we...

Detailed explanation of basic concepts of HTML

What is HTML? HTML is a language used to describe...

Detailed explanation of the use of MySQL select cache mechanism

MySQL Query Cache is on by default. To some exten...

vue-table implements adding and deleting

This article example shares the specific code for...

Multiple ways to change the SELECT options in an HTML drop-down box

After the form is submitted, the returned HTML pag...

Solve the problem that PhpStorm fails to connect to VirtualBox

Problem description: When phpstorm's SFTP hos...

React's context and props explained

Table of contents 1. context 1. Usage scenarios 2...

Detailed explanation of basic interaction of javascript

Table of contents 1. How to obtain elements Get i...

MySQL 8.0.18 installation and configuration graphic tutorial

Learning objectives: Learn to use Windows system ...

How to install mysql on centos and set up remote access

1. Download the mysql repo source $ wget http://r...