mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-31 05:03:21 +08:00
Adjust builder-vite ssv6
This commit is contained in:
parent
0e8b0ba16f
commit
afaf141041
@ -1,9 +1,16 @@
|
||||
import { isAbsolute, resolve } from 'path';
|
||||
import { getRendererName } from '@storybook/core-common';
|
||||
import { virtualPreviewFile, virtualStoriesFile } from './virtual-file-names';
|
||||
import { transformAbsPath } from './utils/transform-abs-path';
|
||||
import type { ExtendedOptions } from './types';
|
||||
|
||||
function resolveRelativePath(path: string) {
|
||||
// resolve relative paths into absolute paths, but don't resolve "bare" imports
|
||||
if (path?.startsWith('./') || path?.startsWith('../')) {
|
||||
return resolve(path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
export async function generateIframeScriptCode(options: ExtendedOptions) {
|
||||
const { presets } = options;
|
||||
const rendererName = await getRendererName(options);
|
||||
@ -15,7 +22,7 @@ export async function generateIframeScriptCode(options: ExtendedOptions) {
|
||||
|
||||
const absoluteFilesToImport = (files: string[], name: string) =>
|
||||
files
|
||||
.map((el, i) => `import ${name ? `* as ${name}_${i} from ` : ''}'${transformAbsPath(el)}'`)
|
||||
.map((el, i) => `import ${name ? `* as ${name}_${i} from ` : ''}'${resolveRelativePath(el)}'`)
|
||||
.join('\n');
|
||||
|
||||
const importArray = (name: string, length: number) =>
|
||||
|
Loading…
x
Reference in New Issue
Block a user