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

When requiring an image path I have to add .default #145

Closed
jordyvandomselaar opened this issue Apr 12, 2020 · 8 comments
Closed

When requiring an image path I have to add .default #145

jordyvandomselaar opened this issue Apr 12, 2020 · 8 comments

Comments

@jordyvandomselaar
Copy link

When importing an SVG I can require the path just fine

src={require("../assets/svg/dij-slash.svg")}

But when importing a jpg I have to import it like this:

image={require("../assets/img/content/diensten-support.jpg").default}

Notice the .default at the end. Is this intended?

@durchanek
Copy link

Found this happening for images that are not inlined, either because they are too large or because ?url is set. Filetype doesn't seem to matter, happening with SVGs too. Quite problematic because the image can break when its file size changes.
Tested in 2.5.8-canary.1

@calclavia
Copy link

calclavia commented Apr 15, 2020

I'm getting the same issue in v2.5.8 - not sure if it's related to using TypeScript? In my project all image require needs be used with a .default. For example: require('...pathtoimage.png').default. This behavior is strange as it doesn't apply when I use resize (maybe because it uses the responsive loader?). When using webp I have to use .default.

@jordyvandomselaar
Copy link
Author

The issue is definitely as @durchanek described. Ran into the same case yesterday where .default was not required when the image got inlined.

@cyrilwanner
Copy link
Owner

Thank you all for the bug report! It should indeed not require the .default, otherwise, the automatic inlining for smaller images doesn't really make sense.

I think I was now able to reproduce the error. It appears to happen when you either manually install a newer file-loader version or any other plugin/package installs it.

It should now be fixed and I just published a new version: 2.6.0
Can you please try it again with this version? Thanks!

@durchanek
Copy link

@cyrilwanner Working great after the update. Thanks!

@jordyvandomselaar
Copy link
Author

@cyrilwanner that fixed it. Thanks!

@l3v1k
Copy link

l3v1k commented May 22, 2020

This isn't fixed issue for me, but I've fixed it by disabling fallback to url-loader through option inlineImageLimit: -1. Think there may be issue with url-loader's default config?

@Exelord
Copy link

Exelord commented Aug 15, 2020

Confirm. The issue is still there

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

6 participants