79624137

Date: 2025-05-15 20:40:57
Score: 0.5
Natty:
Report link

Side effects raised in the initial question:

  1. Declaration files sprinkled throughout the directory.
  2. Extra time in the CI build step
  3. vite-plugin-dts breaks Storybook production build.

1. Declaration files

To correct this behavior, define the declarationDir in your tsconfig.json file.

{
  "compilerOptions": {
    "declaration": true,
    "declarationDir": "./build",
  },
}

2. Extra time in the CI build step

See next step for removing dts from the Storybook build step.

3. This elaborate's [@dimava's][1] response

you can viteFinal(config){ config.plugins.shift(); return config; } as far as I undestood

//.storybook/maint.ts`

const config: StorybookConfig = {
  // ...
    async viteFinal(config) {
    const { mergeConfig } = await import('vite');
    /**
     * `storybook build` does not reconcile the path correctly for the `vite:dts` plugin and causes the
     * build to fail. By removing the plugin, storybook will successfully build.
     */
    const dtsIndex = config.plugins?.findIndex((plugin) => {
      if (plugin && typeof plugin === 'object' && 'name' in plugin && plugin.name === 'vite:dts') {
        return true;
      }
      return false;
    });

    // Remove `vite:dts` plugin from config.plugins array using the index provided in `dtsIndex`.
    if (dtsIndex !== undefined && dtsIndex !== -1) {
      config.plugins?.splice(dtsIndex, 1);
    }

    return mergeConfig(config, {
      resolve: {
        ...config.resolve,
      },
    });
  },
};


  [1]: https://stackoverflow.com/questions/76017338/prevent-creating-definition-files-d-ts-onstorybook-build-vite-react-library-p#comment134090392_76017338
Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Jared