diff --git a/packages/integrations/image/src/index.ts b/packages/integrations/image/src/index.ts index 80d87fbd1..60e5e1679 100644 --- a/packages/integrations/image/src/index.ts +++ b/packages/integrations/image/src/index.ts @@ -15,7 +15,7 @@ const UNSUPPORTED_ADAPTERS = new Set([ '@astrojs/cloudflare', '@astrojs/deno', '@astrojs/netlify/edge-functions', - '@astrojs/vercel/edge' + '@astrojs/vercel/edge', ]); interface BuildConfig { @@ -107,8 +107,10 @@ export default function integration(options: IntegrationOptions = {}): AstroInte }, 'astro:build:start': ({ buildConfig }) => { const adapterName = _config.adapter?.name; - if(adapterName && UNSUPPORTED_ADAPTERS.has(adapterName)) { - throw new Error(`@astrojs/image is not supported with the ${adapterName} adapter. Please choose a Node.js compatible adapter.`); + if (adapterName && UNSUPPORTED_ADAPTERS.has(adapterName)) { + throw new Error( + `@astrojs/image is not supported with the ${adapterName} adapter. Please choose a Node.js compatible adapter.` + ); } // Backwards compat diff --git a/packages/integrations/image/src/vite-plugin-astro-image.ts b/packages/integrations/image/src/vite-plugin-astro-image.ts index ee06b0d5c..1381ecde1 100644 --- a/packages/integrations/image/src/vite-plugin-astro-image.ts +++ b/packages/integrations/image/src/vite-plugin-astro-image.ts @@ -114,25 +114,25 @@ export function createPlugin(config: AstroConfig, options: Required { - for(const name of Object.keys(chunk.modules)) { - if(name.endsWith('vendor/squoosh/image-pool.js')) { - return '[name].[hash].mjs'; - } - } + const chunkFileNames = outputOptions.chunkFileNames; + outputOptions.chunkFileNames = (chunk) => { + for (const name of Object.keys(chunk.modules)) { + if (name.endsWith('vendor/squoosh/image-pool.js')) { + return '[name].[hash].mjs'; + } + } - if(typeof chunkFileNames === 'function') { + if (typeof chunkFileNames === 'function') { return chunkFileNames.call(this, chunk); } - return chunkFileNames!; - }; - } + return chunkFileNames!; + }; + } }, async renderChunk(code) { const assetUrlRE = /__ASTRO_IMAGE_ASSET__([a-z\d]{8})__(?:_(.*?)__)?/g;