Skip to content

Commit bee7983

Browse files
authored
Fix MDX1 in Windows environments (#560)
1 parent 52763fb commit bee7983

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/builder-vite/plugins/mdx-plugin.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { dirname } from 'node:path';
22
import type { Options } from '@storybook/core-common';
33
import { Plugin } from 'vite';
4+
import slash from 'slash';
45

56
const isStorybookMdx = (id: string) => id.endsWith('stories.mdx') || id.endsWith('story.mdx');
67

@@ -10,10 +11,12 @@ const isStorybookMdx = (id: string) => id.endsWith('stories.mdx') || id.endsWith
1011
* Equivilent to https://github.com/storybookjs/mdx1-csf/blob/d58cb032a8902b3f24ad487b6a7aae11ba8b33f6/loader.js#L12-L16
1112
*/
1213
function injectRenderer(code: string) {
13-
const mdxReactPackage = dirname(
14-
require.resolve('@mdx-js/react/package.json', {
15-
paths: [dirname(require.resolve('@storybook/mdx1-csf/package.json'))],
16-
})
14+
const mdxReactPackage = slash(
15+
dirname(
16+
require.resolve('@mdx-js/react/package.json', {
17+
paths: [dirname(require.resolve('@storybook/mdx1-csf/package.json'))],
18+
})
19+
)
1720
);
1821

1922
return `

0 commit comments

Comments
 (0)