astro-imagetools: Astro 1.0.2: In production, images are not being transformed

Since Astro 1.0.2, the links to images transformed by astro-imagetools are broken in production only, 404. I tried referencing images from .md frontmatter as well as images within .mdx file using the <Picture /> component. While I’m getting the blurred up versions of the images, the link to the final images are all broken and no images have been transformed regardless of what the CLI tells me.

  • The path to my images resides in /public/images since Astro 0.2.x
  • Not using Astro SSR
  • Using Astro 1.0.3, "astro-imagetools": "^0.6.10" with npm

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 11
  • Comments: 21 (3 by maintainers)

Commits related to this issue

Most upvoted comments

+1. This bug is critical. It makes astro-imagetools completely unsustainable to use in the long run, because we cannot update the Astro version until this gets fixed.

@RafidMuhymin any chance we could merge #115 and release a new version? We really need support for Astro v1 here.

Raised a PR to fix this for SSG. SSR with the node adapter still has issues though, despite calling closeBuild, the asset store is empty.

Yep, I’m finding the same that images don’t work when running build/preview, but do work when running develop.

I’ve rolled back to "astro": "1.0.0-rc.7" and everything is working as expected again.

I had tested with all the latest astro versions, up to 1.0.5

npm: https://www.npmjs.com/package/patch-package pnpm: https://pnpm.io/cli/patch yarn: https://yarnpkg.com/cli/patch

With these you should be able to manually add the line from #115 and commit it to git. You may need to use "astro:build:done" as the hook (https://github.com/RafidMuhymin/astro-imagetools/pull/115#issuecomment-1230936973)

I have had the patch applied for a few days and the build seems fine

@Tc-001 I think the easiest is to put those lines in your Astro config file:

astroImageTools.hooks['astro:build:done'] = async () =>
  (await import("./node_modules/astro-imagetools/plugin/hooks/closeBundle.js")).default();

I confirm the issue is still present with Astro v1.0.8. I hope this to be fixed asap. It is indeed a critical issue.

I could temporarily solve the problem with the fix submitted by @npmrun, https://github.com/RafidMuhymin/astro-imagetools/issues/111#issuecomment-1223765068 Thank you very much!

node_modules\astro-imagetools\integration\index.js add this code

export default {
  name: "astro-imagetools",
  hooks: {
    "astro:config:setup": ......,
     // add this code
    async "astro:build:done"(){
        const { default: closeBundle } = await import("../plugin/hooks/closeBundle.js");
        await closeBundle()
    }
  },
};

It worked for me ,I think this is not a good way to solve it, but that’s all I can do for now