Open theorib opened 4 months ago
Certainly, at least for .cjs
, support is mandatory!
Support was added in v4.5.0 for .cjs
!
https://github.com/dc7290/next-export-optimize-images/releases/tag/v4.5.0
I think this may be related, but when I updated from 3.3.0 to 4.5.0, all of my pages returned 404 not found error. My config file is using mjs (next.config.mjs) which may be the culprit. I just reverted back to 3.3.0 for now which works fine. I'm on Windows 10 using Chrome.
I think this may be related, but when I updated from 3.3.0 to 4.5.0, all of my pages returned 404 not found error. My config file is using mjs (next.config.mjs) which may be the culprit. I just reverted back to 3.3.0 for now which works fine. I'm on Windows 10 using Chrome.
In all probability, the fact that you were using next.config.mjs would not have caused the bug you are seeing. I had been using it like that before the latest version without any issues. That last update was to support using .cjs
extension in the export-images.config
file instead. It's possible the bug you are seeing is happening for a different reason.
Thanks for the info @theorib. I don't have time to dig into the bug right now, but I will later when I have a chance. Much appreciated.
Describe the bug
next-export-optimize-images fails to recognise
export-images.config
files that use either.cjs
or.mjs
extensions. It only recognises files with a.js
extension.This severely limits the library usage since depending on your project configuration, by not using either
.cjs
or.mjs
extensions it's not possible for the config file to resolve imports correctly.I have tried this with both the current (v4.4.0) and the previous version of the library. I have also tried this with different content inside the
export-images.config.cjs
.To Reproduce Steps to reproduce the behavior:
export-images.config.cjs
orexport-images.config.mjs
file instead ofexport-images.config.js
regardless of its content.npm run dev
ornpm run build
)info - [next-export-optimize-images]: Configuration was not loaded. (This is optional.)
Expected behavior The library should be able to recognise at least
export-images.config.cjs
config files. If the developer wishes to support ESM files that would be even better but it's not necessary to solve this issue.Desktop (please complete the following information):
Here is my
next.config.mjs
file*Here is my
export-images.config.cjs
fileAdditional context
If at any point I remove the
.cjs
extension from my file. I get the following error in my terminal when building or running the project in dev mode. Bear in mind this problem is not related to using url path aliases as it also does not work when using relative paths for the imports. I tried doing this in multiple different ways.If I remove all the imports and hardcode values, this library works as intended.