Tovarisch
Tovarisch

Reputation: 59

Vue.js builder produces incorrect paths in index.html

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', //...

Upvotes: 2

Views: 1818

Answers (1)

Maverick Fabroa
Maverick Fabroa

Reputation: 1173

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

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

Read more in the official documentation: publicPath

Upvotes: 4

Related Questions