Skip to content

Commit

Permalink
Fix MDX1 in Windows environments (#560)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwooding committed Feb 13, 2023
1 parent 52763fb commit bee7983
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/builder-vite/plugins/mdx-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { dirname } from 'node:path';
import type { Options } from '@storybook/core-common';
import { Plugin } from 'vite';
import slash from 'slash';

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

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

return `
Expand Down

0 comments on commit bee7983

Please sign in to comment.