twopluszero / next-images

Import images in Next.js (supports jpg, jpeg, svg, png and gif images)
MIT License
949 stars 67 forks source link

v1.8.3 has broken some image imports #81

Closed marcjlyoung closed 2 years ago

marcjlyoung commented 2 years ago

Not to sure what happened but reverting to 1.8.2 without ^ solves the issue :)

`./src/images/buttons/searchButton.svg 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"?> | | <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" `

marcjlyoung commented 2 years ago

How to fix the last commit

Why its broken:

Seems the regex is not escaped correctly using new RegExp

image

Solution: new RegExp('\\.\\w+(?<!(s?c|sa)ss)$', 'i')

Temp solution

Adjust package.json to 1.8.2 without caret (^)

marcjlyoung commented 2 years ago

@marcjlyoung Could you help me with creating a PR?

Unfortunately I won't be able to assist right now, I quickly posted the solution so you could test it. I'm away from my rig

arefaslani commented 2 years ago

@marcjlyoung Just added the fix and published a new version. Thanks for the help 👍 Do you think this change is in conflict with this PR? CC @lvancraen

marcjlyoung commented 2 years ago

No don't think there is a conflict, I just fixed the new regex param so that it created the same output as was previously there in v1.8.2, since it's still using the new regex function safari should be okay 👍