From 97c5514afcd718665b43dcfb9d26c92d47eebd7a Mon Sep 17 00:00:00 2001 From: Josh Wooding <12938082+joshwooding@users.noreply.github.com> Date: Mon, 14 Nov 2022 01:45:17 +0000 Subject: [PATCH] Fix preview annotations with the Vite builder on Windows --- .../lib/builder-vite/src/utils/process-preview-annotation.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/lib/builder-vite/src/utils/process-preview-annotation.ts b/code/lib/builder-vite/src/utils/process-preview-annotation.ts index ecf811293ce5..489c0071f00e 100644 --- a/code/lib/builder-vite/src/utils/process-preview-annotation.ts +++ b/code/lib/builder-vite/src/utils/process-preview-annotation.ts @@ -1,5 +1,6 @@ import type { PreviewAnnotation } from '@storybook/types'; import { resolve } from 'path'; +import slash from 'slash'; /** * Preview annotations can take several forms, and vite needs them to be @@ -21,7 +22,7 @@ export function processPreviewAnnotation(path: PreviewAnnotation | undefined) { } // resolve relative paths into absolute paths, but don't resolve "bare" imports if (path?.startsWith('./') || path?.startsWith('../')) { - return resolve(path); + return slash(resolve(path)); } // This should not occur, since we use `.filter(Boolean)` prior to // calling this function, but this makes typescript happy @@ -29,5 +30,5 @@ export function processPreviewAnnotation(path: PreviewAnnotation | undefined) { throw new Error('Could not determine path for previewAnnotation'); } - return path; + return slash(path); }