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

NextJS 7+ /_next/static/images to /_next/static/{buildid}/images #64

Closed
msreekm opened this issue Mar 1, 2019 · 1 comment
Closed

Comments

@msreekm
Copy link

msreekm commented Mar 1, 2019

How does this plugin work with NextJS 7+? in next.js 7+ the build output was changed from from /_next/static/images to /_next/static/{buildid}/images

@cyrilwanner
Copy link
Owner

Hi @msreekm
This plugin actually doesn't use the buildid folder on purpose. The reason is that the images already have a hash of their content included in the filename (/_next/static/images/avatar-1e8c19705d29f56c9eb7156443769215.png). If an image gets changed/overwritten, the hash will also change and so gets a new filename and the new image gets required anywhere (also on a cdn etc).
If it would be within the build folder, the image would always have a new url on a new build, even if it wasn't changed (and images usually don't change that often), and so it can't be requested from browser cache and also needs to be cached separately on a cdn. So, it was a performance decision to not use this buildid folder.

It still puts all images within /_next/static/images which isn't a problem at all, they still get served correctly.

Did you encounter a problem with this approach or would you still like to put them into the buildid folder, regardless of the performance argument?

We actually already provide a setting to overwrite the target folder (https://github.com/cyrilwanner/next-optimized-images#imagesfolder), if you want, I can easily extend this setting to also allow a function which gets the buildid as an argument, so you could put them into this folder (e.g. (buildId) => `${buildId}/images` ).

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

2 participants