Skip to content

Commit

Permalink
fix: 🐛 fix dev server on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
DerZade committed Jun 8, 2024
1 parent c6cea42 commit 51536f9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createFilter, type Plugin } from 'vite';
import { ESLiteral, toESString } from './utils/toESString';
import { readFile } from 'node:fs/promises';
import { parse } from 'node:path';
import { parse, basename } from 'node:path';
import sharp from 'sharp';
import mime from 'mime';

Expand Down Expand Up @@ -95,10 +95,12 @@ export default function srcsetPlugin(options: SrcsetPluginConfig = []): Plugin {

const config = findConfig(idWithoutParams);

const importPath = './' + basename(idWithoutParams);

if (viteCommand === 'serve') {
// we just serve the image during dev server operation
return {
code: `import imgUrl from '${idWithoutParams}?url';
code: `import imgUrl from '${importPath}?url';
export default ${toESString({
sources: [
Expand Down

0 comments on commit 51536f9

Please sign in to comment.