diff --git a/.changeset/quiet-bulldogs-appear.md b/.changeset/quiet-bulldogs-appear.md new file mode 100644 index 00000000..6a33259a --- /dev/null +++ b/.changeset/quiet-bulldogs-appear.md @@ -0,0 +1,5 @@ +--- +"vite-imagetools": patch +--- + +Support Vite's `server.origin` option diff --git a/packages/vite/src/index.ts b/packages/vite/src/index.ts index d7d13e51..1eda4c25 100644 --- a/packages/vite/src/index.ts +++ b/packages/vite/src/index.ts @@ -128,7 +128,7 @@ export function imagetools(userOptions: Partial = {}): Plugin if (viteConfig.command === 'serve') { const id = await generateImageID(srcURL, config, img) generatedImages.set(id, image) - metadata.src = basePath + id + metadata.src = path.posix.join(viteConfig?.server?.origin ?? '', basePath) + id } else { const fileHandle = this.emitFile({ name: basename(srcURL.pathname, extname(srcURL.pathname)) + `.${metadata.format}`,