Open bruceharrison1984 opened 1 year ago
When using this library for SSG scenarios like NextJS, it's necessary to use a dynamic import otherwise the build fails with self is not defined.
self is not defined
For NextJS, this looks like the following:
const { readAndCompressImage } = (await import('browser-image-resizer'));
This is because the static generation doesn't have access to the browser context. Otherwise it works great!
Great feedback, thanks @bruceharrison1984! I'll throw that in the README.md
When using this library for SSG scenarios like NextJS, it's necessary to use a dynamic import otherwise the build fails with
self is not defined
.For NextJS, this looks like the following:
This is because the static generation doesn't have access to the browser context. Otherwise it works great!