diff --git a/.changeset/new-otters-turn.md b/.changeset/new-otters-turn.md new file mode 100644 index 00000000..65a1e392 --- /dev/null +++ b/.changeset/new-otters-turn.md @@ -0,0 +1,5 @@ +--- +'vite-imagetools': patch +--- + +fix: correct URL concatenation in dev mode when origin set in server options diff --git a/packages/vite/src/index.ts b/packages/vite/src/index.ts index f033f115..767369f2 100644 --- a/packages/vite/src/index.ts +++ b/packages/vite/src/index.ts @@ -1,5 +1,4 @@ import { basename, extname } from 'node:path' -import { join } from 'node:path/posix' import { statSync, mkdirSync, createReadStream } from 'node:fs' import { writeFile, readFile, opendir, stat, rm } from 'node:fs/promises' import type { Plugin, ResolvedConfig } from 'vite' @@ -167,7 +166,7 @@ export function imagetools(userOptions: Partial = {}): Plugin : await readFile(`${cacheOptions.dir}/${id}`) ).toString('base64')}` } else if (viteConfig.command === 'serve') { - metadata.src = join(viteConfig?.server?.origin ?? '', basePath) + id + metadata.src = (viteConfig?.server?.origin ?? '') + basePath + id } else { const fileHandle = this.emitFile({ name: basename(pathname, extname(pathname)) + `.${metadata.format}`,