Search code examples
javascripthtmlgoogle-chromevue.jsprogressive-web-apps

Uncaught SyntaxError: Unexpected token '<' VueJS PWA


When I generate the production version of my PWA built with VueJS I got this error in Google Chrome after deploying it to my server:

  • Uncaught SyntaxError: Unexpected token '<' in app.21fde857.js:1
  • Uncaught SyntaxError: Unexpected token '<' in chunk-vendors.d1f8f63f.js:1

I take a look in the Network tab of the console and in both files chunk-vendors.d1f8f63f.js and app.21fde857.js the index.html is coming back with a status 200.

Why this occurs?

OBS: Locally this works perfectly.


Solution

  • Here is a solution that doesn't require hand-editing your dist assets. Simply add the following property to the exports of your vue.config.js:

    publicPath: './'