Skip to content

Commit

Permalink
fix(builder-vite): Load vite config with correct root
Browse files Browse the repository at this point in the history
  • Loading branch information
nVitius committed Jun 8, 2023
1 parent 4678e0c commit 8ccd904
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 @@ -43,16 +43,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: 'node_modules/.cache/.vite-storybook',
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 8ccd904

Please sign in to comment.