-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Relative static assets in CSS folder #932
Comments
Just commenting to let you know that I intend to look into this, but it wil require to make thorough tests of various scenarios, especially nested routes in vue-router, so see if that fix actually works across all of them. So please be patient, It's not forgotten, but not done with a simple change, at least not if we want the template to be thoroughly tested. |
So I tried to reproduce it, but still can't, |
Hello, I've a similar issue but in DEV. When I run 'npm run dev', I get no errors related to the image URL path. The image simply does NOT display in the background. After going through the issues related to this problem in detail, I tried all possible paths in hopes of getting it right: ../../assets/logo.png, but no luck. I did modify the 'webpack.base.conf.js' file to include the below line, as suggested by @githoniel in #208
Not sure if this matters, but in the same file, I have for the vue-loader:
Image path AppShell.vue CODE template
script
CSS
The repo is hosted at https://github.com/sikanderv/vue-projects/tree/master/driving-school if someone would like to take a look at it. Screenshot of the page and Dev Tools: |
your problem is not a problem related to paths. You are dynamically constructing CSS styles at runtime. Webpack can't recognize that at build time without some help. That help is data () {
return {
msg: 'My Driving School',
tabIndex: 0,
image: require('../../assets/logo.png')
}
} |
Thank you very much, this works. Guess I have some reading to do about Webpack. :) |
I'm trying to deploy into a sub folder on the production server, and using
in vue.config.js works fine for the javascript files, however the background image urls in the styles don't work e.g.
does not become
I've tried removing the absolute path / from the front of the url and also tried using ./ but nether of these will compile into a valid Vue.js application, I've also tried setting the assets path in the config e.g. https://cli.vuejs.org/config/#assetsdir setting it to './' or '/assets' but this doesn't work either, as normally the build fails Is there a workaround for this problem ? |
Try this vuejs/vue-loader#646 (comment) |
Just opening a new issue confirming that bug #208 still exists and @githoniel's solution is still necessary today.
This has all to do with using relative paths in CSS files.
The text was updated successfully, but these errors were encountered: