Skip to content

Commit

Permalink
Merge branch 'tom/fix-losing-args-on-hmr' of https://github.com/story…
Browse files Browse the repository at this point in the history
…bookjs/storybook into tom/fix-losing-args-on-hmr
  • Loading branch information
ndelangen committed Apr 29, 2024
2 parents 1a22b41 + 7cf08a8 commit 4482c8f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions code/builders/builder-vite/src/assetsInclude.ts
@@ -0,0 +1,15 @@
import type { InlineConfig as ViteInlineConfig } from 'vite';

export function getAssetsInclude(config: ViteInlineConfig, newPath: string[]): (string | RegExp)[] {
const { assetsInclude } = config;

if (!assetsInclude) {
return newPath;
}

if (Array.isArray(assetsInclude)) {
return [...assetsInclude, ...newPath];
} else {
return [assetsInclude, ...newPath];
}
}
3 changes: 2 additions & 1 deletion code/builders/builder-vite/src/vite-server.ts
Expand Up @@ -3,6 +3,7 @@ import type { Options } from '@storybook/types';
import { commonConfig } from './vite-config';
import { getOptimizeDeps } from './optimizeDeps';
import { sanitizeEnvVars } from './envs';
import { getAssetsInclude } from './assetsInclude';

export async function createViteServer(options: Options, devServer: Server) {
const { presets } = options;
Expand All @@ -12,7 +13,7 @@ export async function createViteServer(options: Options, devServer: Server) {
const config = {
...commonCfg,
// Needed in Vite 5: https://github.com/storybookjs/storybook/issues/25256
assetsInclude: ['/sb-preview/**'],
assetsInclude: getAssetsInclude(commonCfg, ['/sb-preview/**']),
// Set up dev server
server: {
middlewareMode: true,
Expand Down

0 comments on commit 4482c8f

Please sign in to comment.