Vue project webpack is packaged and deployed to Tomcat

Create a new Vue project webpack package and deploy it to the Linux server Tomcat.

1. Create a VueTest folder under Tomcat's webapps under the Linux server

2. Configure the router/index.js file, add base: '/VueTest', VueTest is the file path under webapps in Tomcat

3. Run the "cnpm run build" command in the project to generate a dist folder, which contains static and index.html

4. Copy static and index.html in the dist folder to the VueTest folder of webapps in Tomcat

5. Restart Tomcat and access the Linux server ip:8080/VueTest to access the Vue project

Precautions:

(1) In /config/index.js under the template of vue-cli webpack, we can see the assetsPublicPath parameter, changing it from "/" to "./"

(2) Find build->utils.js and add a publicPath in it: "../../"

Configure these two because I see that my data structure is different from the general one, and the following is my data structure

The path to the image in css is

background: url('../../static/img/index.png') no-repeat top left ;

This will give you access to the Vue project

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325074431&siteId=291194637