Skip to content
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

Get image requiring working with url-loader #72

Closed
erikras opened this issue Jul 30, 2015 · 6 comments
Closed

Get image requiring working with url-loader #72

erikras opened this issue Jul 30, 2015 · 6 comments

Comments

@erikras
Copy link
Owner

erikras commented Jul 30, 2015

Ideally we want to use url-loader for image files to capture small files as base64 encoded strings to reduce the number of http requests to the server, but the image requiring solution that solved #39 does not work with url-loader.

Someone needs to investigate. The base64 string is probably in webpack-stats.json somewhere. It's just a matter of making requireServerImage() smart enough to use it instead.

@NogsMPLS
Copy link

FYI, base64 string is inside image.source when using url-loader. But it ends up having the whole module.exports = thing inside it.

Also, the logo image has the base64 in source, but the kitten image has a link to a .jpg named like c29770d03d2e95e3ea5899d57c6cfeab.jpg as opposed to a true base64 data:image kind of thing. Dunno fi that is an issue or working as intended though.

@erikras
Copy link
Owner Author

erikras commented Jul 30, 2015

That's working as intended. It only encodes images under a certain threshold.

@NogsMPLS
Copy link

okay cool. also I think i have a fix. ill get a PR here for you to look at here in a few minutes

@NogsMPLS
Copy link

basically that fix is checking image.source,

finding the index of the first double quote ",

slicing at that point and chopping the last character(also a double quote) off.

then checks if the string starts with data:image.

if it does, then use that, if not then append publicPath to it and use that. Seems to be working for me on Windows, can't test mac.

@erikras
Copy link
Owner Author

erikras commented Jul 30, 2015

Works on Mac. Well done! 👍

@erikras erikras closed this as completed Jul 30, 2015
@leonli
Copy link
Contributor

leonli commented Jul 31, 2015

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants