Search code examples
javascriptvuejs2production

Wrong path to static files in production mode in Vue.js application


I've created an application using Vue.js and run npm run build. After the finishing a process dist folder appeared, BUT paths to static files are wrong. Everywhere it adds '/' before every path. Smth like this: <script type="text/javascript" src="/static/js/app.5563dab9fc515679fa52.js"></script>. But it is wrong. It has to be without a forward slash before static folder.

In development mode the file structure in src looks like:

enter image description here

In production mode like this:

enter image description here


Solution

  • Solved: I just changed index.js file in config folder.

    From: assetsPublicPath: '/'

    To: assetsPublicPath: ''