After the front-end deployment goes online, the screen is blank, and an error of Uncaught SyntaxError: Unexpected token '<' appears

After the front-end goes online and opens a white screen, the error is as follows:

insert image description here

reason

Such problems are generally caused by errors in the resource path we introduced after packaging.

Solution

Modify the publicPath and add the publicPath configuration in config.
Since the formal environment of the project is not deployed at the root of the domain name, the prefix of the formal environment needs to be accompanied by the sub-project path. It is declared in config.js that the prefix of the formal environment needs to be accompanied by "/xxx". Then the BASE_URL here is equivalent to /xxx

publicPath: process.env.NODE_ENV === “production” ? “/xxx” : “/”,

insert image description here

Guess you like

Origin blog.csdn.net/weixin_47541876/article/details/125990393