Vue package to nginx uncaught syntax error: unexpected token < problem solving

Time:2020-10-17

Once the package is online, there will be a problem when it is refreshedVue package to nginx uncaught syntax error: unexpected token < problem solving
I checked a lot of articles and said that it was caused by hash mode, but it was not. The history mode refresh will be 404,
Official website solution, in nginx.conf Document addition

location / {
try_files $uri $uri/ /index.html;
}

Then the above problem will occur because JS file 404 is forcibly converted to index.html
The JS file does not recognize < so it causes problems
So optimize the lower and upper configuration
Change the code in the upper part of {} to the code below to solve the problem perfectly

rewrite ^.+(?<!js|css|png|map)$ /index.html break;

Recommended Today

Construction of Vue development environment and project creation under mac

start First of all, let’s take a look at the overall development environment of Vue. Homebrew: package manager under MAC system, similar to apt get under Linux, windows control panel – install and remove program Node.jsJavaScript runtime, which is similar to simultaneous interpretation in international conferences, can’t run various programming languages directly between different systems […]