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

Can't use .svg?include since 2.5.6 #142

Closed
esiao opened this issue Apr 6, 2020 · 8 comments
Closed

Can't use .svg?include since 2.5.6 #142

esiao opened this issue Apr 6, 2020 · 8 comments

Comments

@esiao
Copy link

esiao commented Apr 6, 2020

Hello,

I've came across an issue recently upgrading my depencies.
It looks like since version 2.5.6 the raw-loader isn't loaded properly and during the build I have errors of the likes of, resulting in error 500.

./assets/something.svg?include 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <?xml version="1.0" encoding="utf-8"?>

If I downgrade to 2.5.5 the issue is gone and I can use my svgs as expected.
const Something = require('../assets/something.svg?include')

Hope this will help people coming across this issue until it's fixed.

Thanks for your hard work.

@cyrilwanner
Copy link
Owner

Hello @esiao
Can you provide me more information about the versions you are using?
Did you also try 2.5.7 (which fixed a similar problem)?
And which nextjs version are you using? Are using the @zeit/next-css|sass plugins or did you migrate to the builtin nextjs css solution (introduced in 9.2/9.3)?
Thank you already!

@kolyasapphire
Copy link

kolyasapphire commented Apr 7, 2020

Hi! Having a similar issue, but for:
require('xxx.jpg?resize')

Getting:

Error: Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)

Next.js: 9.3.4
next-optimized-images 2.5.7

responsive-loader: 1.2.0
sharp: 0.25.2
webp-loader: 0.6.0
imagemin-mozjpeg: 8.0.0
imagemin-optipng: 7.1.0
imagemin-svgo: 7.1.0

@kolyasapphire
Copy link

Tested - this errors are not happening in next-optimized-images 2.5.5, even with latest Next 9.3.4. I am using built-in Next CSS.

@esiao
Copy link
Author

esiao commented Apr 11, 2020

Hello @esiao
Can you provide me more information about the versions you are using?
Did you also try 2.5.7 (which fixed a similar problem)?
And which nextjs version are you using? Are using the @zeit/next-css|sass plugins or did you migrate to the builtin nextjs css solution (introduced in 9.2/9.3)?
Thank you already!

Here are my modules versions

  • next-optimized-images: 2.5.7
  • next: 9.3.4
  • svg-sprite-loader: 4.1.3
  • imagemin-svgo: 7.1.0

I tried with 2.5.7 and 2.5.6, I had to roll back to 2.5.5 where I don't have the issue. (today still)
I'm using the built in sass modules but the icon is in a react component. It's using a dynamic require in the likes of const Icon = require(`[...]/${icon}?include\`) to fetch the icon. Hope this helps.

@cyrilwanner
Copy link
Owner

cyrilwanner commented Apr 11, 2020

That did indeed help, thank you!

I just published a canary version: 2.5.8-canary.1
Can you maybe try this version in your project and tell me if everything works again as expected? If that is the case and I am sure it doesn't break anything else, I will release it with the latest tag.

@kolyasapphire
Copy link

Fixed the issue for me, thank you very much!

@esiao
Copy link
Author

esiao commented Apr 20, 2020

That did indeed help, thank you!

I just published a canary version: 2.5.8-canary.1
Can you maybe try this version in your project and tell me if everything works again as expected? If that is the case and I am sure it doesn't break anything else, I will release it with the latest tag.

Hi I'm sorry I didn't answer earlier I had an hectic week! It's working perfectly fine now, thank you. I'm looking forward the next release with the fix, glad I could help you debug the issue. Thank you very much.

@cyrilwanner
Copy link
Owner

No worries, we all have those weeks.

I'm glad to hear that everything works, thank you again! The fix is now published as a non-canary version in 2.5.8.

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