Skip to content

Commit

Permalink
Fix url concatenation for dev mode with origin set in server options (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dknibbe authored Jul 10, 2024
1 parent 57e070e commit c4a0dc7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-otters-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vite-imagetools': patch
---

fix: correct URL concatenation in dev mode when origin set in server options
3 changes: 1 addition & 2 deletions packages/vite/src/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -167,7 +166,7 @@ export function imagetools(userOptions: Partial<VitePluginOptions> = {}): 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}`,
Expand Down

0 comments on commit c4a0dc7

Please sign in to comment.