Niels-IO / next-image-export-optimizer

Use Next.js advanced <Image/> component with the static export functionality. Optimizes all static images in an additional step after the Next.js static export.
413 stars 51 forks source link

Output folder not being created on build. #199

Closed joebentaylor1995 closed 5 months ago

joebentaylor1995 commented 5 months ago

After battling with 10 errors for 3 images in the console log for a couple of hours I realised, that when running next build && next-image-export-optimizer and then serving this, the assets folder for the optimised images never gets made or generated.

I have the exact same config as the docs, but i looked in the out folder and there are no optimised images folder anywhere.

Using Next 14.1.0 Screenshot 2024-01-29 at 17 38 40

joebentaylor1995 commented 5 months ago

Screenshot 2024-01-29 at 17 40 06 Screenshot 2024-01-29 at 17 42 46

Niels-IO commented 5 months ago

Hi @joebentaylor1995,

Just to be sure: did you change the build script in package.json?

joebentaylor1995 commented 5 months ago

Yes i did (it doesnt have the next export as next config is suggested to have the export enabled under output: 'export') Screenshot 2024-01-29 at 18 34 12

joebentaylor1995 commented 5 months ago

So, i usually run: npm run build && npm run serve to view locally the entire build

Niels-IO commented 5 months ago

@joebentaylor1995 Do you only have remote images? Have you created a remoteOptimizedImages.js as detailed in the README?

I just tested the library with the newest Next.js version and the optimized images are generated as expected.

What is the terminal output for the build script?

joebentaylor1995 commented 5 months ago

No, my images are all local.

My terminal output: Screenshot 2024-01-30 at 12 43 50

Niels-IO commented 5 months ago

It seems that you have no pictures in the "public/images" folder, and not used static import for images. In your posted example above you are using a remote image.

How are you using the ExportedImage component?

joebentaylor1995 commented 5 months ago

Og theres plenty of images in the public folder...

The dummyData images are what im trying to use

Screenshot 2024-01-30 at 12 49 10

joebentaylor1995 commented 5 months ago

DummyData as a const in page.jsx

passed via props Screenshot 2024-01-30 at 12 49 53

into this: Screenshot 2024-01-30 at 12 49 45

Niels-IO commented 5 months ago

In your next.config.js you specified "public/images" as the image folder where this library looks for images. Change that to "public/dummydata" or move all your images to the "public/images" folder...

joebentaylor1995 commented 5 months ago

Okay,. will give that a go now, I may have overlooked the folder

joebentaylor1995 commented 5 months ago

I think we can close this now, thanks for the help @Niels-IO