drake035
drake035

Reputation: 2877

Npm run build generates wrong paths

To deploy my Vue Cli 3 project I did npm run build, however index.html in the new dist/ folder contains wrong paths like this:

<link href=/css/app.35dee36a.css
<link href=/js/app.826dde09.js

as a result I get those in the console:

Failed to load resource - http://my_site.com/js/app.826dde09.js

It should be http://my_site.com/timelog/js, not http://my_site.com/js.

I tried to specify URLs in package.json by adding "baseUrl": "http://my_site.com/timelog/", "homepage": "http://my_site.com/timelog/", but it doesn't change anything.

What is causing this problem and how to solve it?

Upvotes: 5

Views: 2722

Answers (1)

drake035
drake035

Reputation: 2877

I solve this by creating a vue.config.js file at the root of my project with the following content:

module.exports = {
  baseUrl: '/timelog/'
}

(to make internal links work as well see this answer)

Upvotes: 6

Related Questions