#Vite config cacheDir reload hot reload package

3 messages · Page 1 of 1 (latest)

digital obsidian
#

Hello,

I'm using the latest version of storybook.

I use the react version with vite, the template recommended in the documentation.

I have a component library. As soon as I update this library, the storybook doesn't take into account the changes made in the components. Because it uses the cache in node_module/.cache/sb-vite except that I'm obliged to always delete this cache folder in the node module in order to have the modification of my component. I searched and found this in your code:

  const sbConfig: InlineConfig = {
    configFile: false,
    cacheDir: findCacheDirectory({ name: 'sb-vite' }),
    root: projectRoot,
    // Allow storybook deployed as subfolder.  See https://github.com/storybookjs/builder-vite/issues/238
    base: './',
    plugins: await pluginConfig(options),
    resolve: {
      preserveSymlinks: isPreservingSymlinks(),
      alias: {
        assert: require.resolve('browser-assert'),
      },
    },
    // If an envPrefix is specified in the vite config, add STORYBOOK_ to it,
    // otherwise, add VITE_ and STORYBOOK_ so that vite doesn't lose its default.
    envPrefix: userConfig.envPrefix ? ['STORYBOOK_'] : ['VITE_', 'STORYBOOK_'],
  };

  const config: ViteConfig = mergeConfig(userConfig, sbConfig);

in the code/builder/builder-vite/src/vite-config.ts folder.

the problem is that I can't specify false to the cacheDir option because the userConfig is overridden by sbConfig...

My question is how can I avoid taking cache into account in node modules, or is it possible to override this config so as not to have cache?

Thx 🙂

#

it would also allow me to use yalc behind the scenes and do a live reload of my library in order to bug my components and see the result instantly in the storybook.

supple scarab
#

You can change the final vite config that storybook uses by specifying viteFinal in your .storybook/main.ts