Skip to content

Commit

Permalink
refactor a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
bashmish committed May 28, 2024
1 parent 09f0333 commit a137a70
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/storybook-builder/src/generate-app-script.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// based on https://github.com/storybookjs/storybook/blob/v7.0.9/code/lib/builder-vite/src/codegen-modern-iframe-script.ts

import { normalizePath } from '@rollup/pluginutils';
import { loadPreviewOrConfigFile } from '@storybook/core-common';
import type { Options, PreviewAnnotation } from '@storybook/types';
import { virtualSetupAddonsFilename, virtualStoriesFilename } from './virtual-file-names.js';
Expand All @@ -23,7 +24,9 @@ export async function generateAppScript(options: Options) {
const getPreviewAnnotationsFunction = `
const getProjectAnnotations = async () => {
const configs = await Promise.all([
${previewAnnotationURLs.map(previewAnnotation => ` import('${previewAnnotation.replace(/\\/g, '/')}')`).join(',\n')}
${previewAnnotationURLs
.map(previewAnnotation => ` import('${normalizePath(previewAnnotation)}')`)
.join(',\n')}
]);
return composeConfigs(configs);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/storybook-builder/src/generate-stories-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function toImportFn(stories: string[]) {
}

const importPath = toImportPath(relativePath);
let actualPath = path.join(process.cwd(), relativePath).replace(/\\/g, '/');
let actualPath = file;
if (actualPath.endsWith('.mdx')) {
actualPath = `${actualPath}.js`;
}
Expand Down

0 comments on commit a137a70

Please sign in to comment.