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

Steps for installing MySQL 8.0.16 on Windows and solutions to errors

1. Introduction: I think the changes after mysql8...

MySQL master-slave replication principle and points to note

Written in front I have been writing a special to...

mysql 5.7.18 winx64 password change

After MySQL 5.7.18 is successfully installed, sin...

Detailed explanation of the text-fill-color property in CSS3

What does text-fill-color mean? Just from the lit...

Implementation of Jenkins+Docker continuous integration

Table of contents 1. Introduction to Jenkins 2. I...

Detailed tutorial on installing Python 3.6.6 from scratch on CentOS 7.5

ps: The environment is as the title Install possi...

Detailed explanation of the entry-level use of MySql stored procedure parameters

Use of stored procedure in parameters IN paramete...

How MySQL supports billions of traffic

Table of contents 1 Master-slave read-write separ...

Tomcat configuration and how to start it in Eclipse

Table of contents How to install and configure To...

(MariaDB) Comprehensive explanation of MySQL data types and storage mechanisms

1.1 Data Type Overview The data type is a field c...

Example code for implementing a simple search engine with MySQL

Table of contents Preface Introduction ngram full...

Detailed explanation of the practical use of HTML table layout

When is the table used? Nowadays, tables are gene...

How to deploy LNMP & phpMyAdmin in docker

Environmental preparation: Deploy lnmp on a host ...

Share a Markdown editor based on Ace

I think editors are divided into two categories, ...