twopluszero / next-images

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

Allow the ability to control the file suffixes `next-images` cares about #49

Closed kylemh closed 4 years ago

kylemh commented 4 years ago

Resolves https://github.com/twopluszero/next-images/issues/24 (even though it's already closed 😅 )

I don't want to force my team into putting SVGs into one specific folder. I like the simplicity of next-images for most image types, but I'm using SVGR for .svg file types. This lets me exclude SVGs from next-image's concern, but still place SVG files wherever I please.

Alternative

If this isn't ideal for the library author, I could also do a non-breaking change where exclude can be an array of the possible file types, and construct the regex in a similar fashion. In other words, if Array.isArray(nextConfig.excludes), then dont add the exclude property to the loader and - instead - remove each item in the excludes array from the test regex.

arefaslani commented 4 years ago

@kylemh Sorry for the late response. I like the solution 👏 but I'm also thinking that maybe it's better to touch the config file as few as possible. So maybe it's better to do it in the opposite way and just mention the extensions we want to ignore?

kylemh commented 4 years ago

To be clear, @arefaslani you're asking me to do the alternative I recommended?

arefaslani commented 4 years ago

@kylemh Yes and thanks for the help :)

kylemh commented 4 years ago

I personally like the solution I have here, since it's not a breaking change in terms of semantic versioning. exclude already accepts an array as a valid solution, so we'd be going against the normal behavior of webpack loaders.

Additionally, people will be able to upgrade this dependency with no fear of problems, as it's a new config key.

kylemh commented 4 years ago

Thank you!