Vue.js builder produces incorrect paths in index.html

Viewed 423

The problem is that after building vue app in destination folder there is index.html with incorrect paths to static assets. Links look like

<link href="/static/js/chunk-29e00bf1.49e28fbb.js" rel="prefetch">

which is incorrect, but should be

<link href="static/js/chunk-29e00bf1.49e28fbb.js" rel="prefetch">

And browser look into ///D:/static/js/ instead of D://.../build/dist/static/js .

There is my vue.config.js

module.exports = {
  outputDir: './build/dist/',
  assetsDir: './static', //...
1 Answers

Use publicPath property, and set the path to ./ to use relative paths on build.

module.exports = {
    ...
    publicPath: "./"
    ...
}

Read more in the official documentation: publicPath

Related