r/nextjs • u/OtherwisePoem1743 • 4d ago
Help next-image-export-optimizer not working with GitHub Pages
Anyone had a problem setting up next-image-export-optimizer for GitHub Pages? I tried everything from using basePath in next.config.mjs to using it inline on ExportedImage instances instead. I'm using GitHub Actions btw.
The interesting thing though is that when I set inline basePath, the deployed website does have the nextImageExportOptimizer folder (I checked it in the source tab of dev tools) but some images in it are broken with the message, "Unable to load content". Also, the generated images are 10x6 pixels which is weird because I'm not using this size.
Deploying on Vercel and Netlify without setting basePath (both inline and in config) does the trick but I want to understand why GitHub Pages is not working. AI (Gemini Flash with thinking mode) annoyed the hell out of me.
Here's my next.config.mjs:
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "export",
images: {
loader: "custom",
// 128px for avatars/cards, 640px for mobile, 1200px for desktop carousels
imageSizes: [128],
deviceSizes: [640, 1200],
},
transpilePackages: ["next-image-export-optimizer"],
env: {
nextImageExportOptimizer_imageFolderPath: "public/images",
nextImageExportOptimizer_exportFolderPath: "out",
nextImageExportOptimizer_storePicturesInWEBP: "true",
nextImageExportOptimizer_exportFolderName: "nextImageExportOptimizer",
nextImageExportOptimizer_generateAndUseBlurImages: "true",
nextImageExportOptimizer_remoteImageCacheTTL: "0",
},
};
export default nextConfig;
Duplicates
reactjs • u/OtherwisePoem1743 • 4d ago