Skip to content

Commit

Permalink
add projectRoot
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Aug 22, 2024
1 parent e23fef9 commit c9107a1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion code/builders/builder-vite/src/codegen-importfn-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ export async function generateImportFnScriptCode(options: Options): Promise<stri

// We can then call toImportFn to create a function that can be used to load each story dynamically.
// eslint-disable-next-line @typescript-eslint/return-await
return await toImportFn(options.root || process.cwd(), stories);
return await toImportFn(options.projectRoot || process.cwd(), stories);
}
6 changes: 3 additions & 3 deletions code/builders/builder-vite/src/vite-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ export async function commonConfig(

const { viteConfigPath } = await getBuilderOptions<BuilderOptions>(options);

const projectRoot = resolve(options.configDir, '..');
options.projectRoot = options.projectRoot || resolve(options.configDir, '..');

// I destructure away the `build` property from the user's config object
// I do this because I can contain config that breaks storybook, such as we had in a lit project.
// If the user needs to configure the `build` they need to do so in the viteFinal function in main.js.
const { config: { build: buildProperty = undefined, ...userConfig } = {} } =
(await loadConfigFromFile(configEnv, viteConfigPath, projectRoot)) ?? {};
(await loadConfigFromFile(configEnv, viteConfigPath, options.projectRoot)) ?? {};

const sbConfig: InlineConfig = {
configFile: false,
cacheDir: resolvePathInStorybookCache('sb-vite', options.cacheKey),
root: projectRoot,
root: options.projectRoot,
// Allow storybook deployed as subfolder. See https://github.com/storybookjs/builder-vite/issues/238
base: './',
plugins: await pluginConfig(options),
Expand Down
1 change: 1 addition & 0 deletions code/core/src/types/modules/core-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export interface BuilderOptions {
ignorePreview?: boolean;
cache?: FileSystemCache;
configDir: string;
projectRoot?: string;
docsMode?: boolean;
features?: StorybookConfigRaw['features'];
versionCheck?: VersionCheck;
Expand Down

0 comments on commit c9107a1

Please sign in to comment.