Vue3 cannot run after packaging

  1. describe

After using Vue3 to package the project, it cannot be opened with Live Server, and it is the same when it is placed on the server. Error as shown:

  1. analyze

The error message is that the js file is not found, so it may be a problem with the path. About Vue public base path: https://cn.vitejs.dev/guide/build.html#public-base-path . Configure the base path.

3. Solve

The packaged dist file structure is as follows:

It can be seen that the js file is under the assets file in the same level directory as the html file. Then find the vite.config.js configuration file of the Vue project and configure the base path as follows:

It ran successfully after repackaging.

Guess you like

Origin blog.csdn.net/qq_26540577/article/details/129487733