Skip to content

Commit

Permalink
Merge pull request #22240 from nVitius/fix/vite-package-root
Browse files Browse the repository at this point in the history
Fix vite config loading
  • Loading branch information
ndelangen committed Jul 31, 2023
2 parents dc9ac08 + 7c19a49 commit 3bf0237
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions code/builders/builder-vite/src/vite-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@ export async function commonConfig(
const configEnv = _type === 'development' ? configEnvServe : configEnvBuild;
const { viteConfigPath } = await getBuilderOptions<BuilderOptions>(options);

const projectRoot = path.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)) ?? {};
(await loadConfigFromFile(configEnv, viteConfigPath, projectRoot)) ?? {};

const sbConfig: InlineConfig = {
configFile: false,
cacheDir: findCacheDirectory({ name: 'sb-vite' }),
root: path.resolve(options.configDir, '..'),
root: projectRoot,
// Allow storybook deployed as subfolder. See https://github.com/storybookjs/builder-vite/issues/238
base: './',
plugins: await pluginConfig(options),
Expand Down

0 comments on commit 3bf0237

Please sign in to comment.