-
Notifications
You must be signed in to change notification settings - Fork 4.4k
"srcset" doesn't seem to be working #396
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
Comments
I try to your recipe. Unfortunately it does not work. <!-- Example.vue -->
<img src="./assets/photo.jpg" srcset="./assets/photo.jpg 1x, ./assets/[email protected] 2x">
<!-- Renderd -->
<img src="/static/img/photo.jpg" srcset="./assets/photo.jpg 1x, ./assets/[email protected] 2x">
<img src="data:image/png;base64,..." srcset="./assets/photo.jpg 1x, ./assets/[email protected] 2x">
<!-- Expected -->
<img src="/static/img/photo.jpg" srcset="/static/img/photo.jpg 1x, /static/img/[email protected] 2x">
<img src="data:image/png;base64,..." srcset="data:image/png;base64,... 1x, data:image/png;base64,... 2x"> <!-- really? --> Also I found it related base64 encoding loader(probably url-loader?). But I am not sure |
It seems that So I guess you have to do this manually, by importing the impages in the Javascript and using a templatze literal: var photos = {
1: require('./assets/photo.jpg'),
2: require('./assets/[email protected]')
}
export default {
// ...component stuff
computed: {
photos() { return photos }
}
} <img src="/static/img/photo.jpg" v-bind:srcset="`${photos.1} 1x, ${photos.1} 2x`"> If your webpack config has a require('!!url-loader?limit=0!./assets/photo.jpg') |
I made a PR. (vuejs/vue-loader#953) |
Uh oh!
There was an error while loading. Please reload this page.
Here is my file structure.
Below is what I am trying to.
Maybe html-loader support srcset, but vue-html-loader does not support it?
Looks like same problem here.
https://stackoverflow.com/questions/40733102/vue-webpack-project-img-cannot-load-static-src
The text was updated successfully, but these errors were encountered: