Skip to content

npm run build asset path incorrect #1266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
serak opened this issue Jan 24, 2018 · 9 comments
Closed

npm run build asset path incorrect #1266

serak opened this issue Jan 24, 2018 · 9 comments

Comments

@serak
Copy link

serak commented Jan 24, 2018

webpack template static path on build prod should be fixed... all the assets are currently build as src=static/js/..... which on windows os or xampp apache is undefined path unless i change all to ./static/js/ ....

root path : http://localhost/prodbuild/

static path on npm run build : static/[js/css]/....

in which the browser is assuming the assets are on http://localhost/static/[js/css/]/... instead of http://localhost/prodbuild/static/[js/css]/...

thanks

@LinusBorg
Copy link
Contributor

I'm not 100% sure I understand your issue, but;

in which the browser is assuming the assets are on http://localhost/static/[js/css/]/... instead of http://localhost/prodbuild/static/[js/css]/...

that's the expoected behaviour if you leave the default setting for the assetsPublicPath``in /config/index.js as it is: `/`.

It's an absolute path, and this behaviour is intended - it's required for vue-router to work correctly in history mode.

You can change the assetsPublicPath under the build: key to something else, e.g. /prodbuild/, or ./ to make it work in your scenario.

@serak
Copy link
Author

serak commented Jan 24, 2018

assetsPublicPath = '' fixed my problem but what about importing font awesome using this import statement and running npm run build

import './assets/font-awesome-4.7.0/css/font-awesome.css'

final output
ERROR FROM CHROME
GET http://localhost/prodvuejs/static/css/static/fonts/fontawesome-webfont.af7ae50.woff2 net::ERR_ABORTED

no idea why static is repeating ? it should be just http://localhost/prodvuejs/static/fonts/fontawesome...

@LinusBorg
Copy link
Contributor

Hm, In guess the hardcoded import for the font in fontawesome is messing something up.

Won'T have much time to look into this in the coming days, sorry.

@LinusBorg
Copy link
Contributor

LinusBorg commented Jan 29, 2018

Try chaging this line:

https://github.com/vuejs-templates/webpack/blob/develop/template/build/webpack.base.conf.js#L79

to this:

name: NODE_ENV === 'production'
  ? utils.assetsPath('../../fonts/[name].[hash:7].[ext]')
  : utils.assetsPath('fonts/[name].[hash:7].[ext]')

@johnellinwood
Copy link

See workaround for issue 1284

@Mrkisha
Copy link

Mrkisha commented Dec 10, 2018

@LinusBorg How can we do this with latest Vue (vue-cli 3)?

@LinusBorg
Copy link
Contributor

LinusBorg commented Dec 10, 2018

You don't have to, it should work.

Ask question on forum.vuejs.org please.

@Mrkisha
Copy link

Mrkisha commented Dec 10, 2018

@LinusBorg it does not work.

generatedindex.html file has absolute paths to js and css.
I need them relative as I'm using domain with path for this app (https://somedoman.com//).

@LinusBorg
Copy link
Contributor

Ask question on forum.vuejs.org please.

@vuejs-templates vuejs-templates locked as resolved and limited conversation to collaborators Dec 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants