First configure config>index.js in the project
It configures the production environment and development environment of webpack
What to modify here is the properties under the build object
The main modification here is assetsPublicPath (the rest of the properties are for you can go to the webpack official website to view the document), this property is to modify the root path of the static resources
Generally speaking, the project will not be placed in the root path of the server (some online say that it can be placed in ./, I can only say that you can adjust it according to the needs of the project)
Then modify the router path
If mode:'history' is set, there will be a problem
When you redirect the URL splicing route in the browser address bar, you will not find static files (I haven't filled in this pit, but Baidu has to set up Tomcat, but after I set it up, it doesn’t work, nor does the official document Given Tomcat's solution, very entangled) Finally, we compromised, removing the mode:'history' and base attributes, although it is not good-looking, but it is better than a blank page.
At this time, the path of the static resource is configured. If you package now, there will be a problem
Because all the static resources in our development environment are local, the path here will be wrong after uploading to Tomcat, and the page shows 404 Cannot find static resources
So we need to find the build->utils.js file and add a new attribute.
Next, execute npm run build and put it on Tomcat, and then run Tomcat.
What's wrong, I hope you can give me some suggestions