I'm working on a component's library using react + typescript . I'm using vite and each time I build storybook, dts plugin runs.
That has 2 side effects:
This is my vite.config.ts
import { defineConfig } from "vite"
import { resolve } from "path"
import dts from "vite-plugin-dts"
import { viteStaticCopy } from "vite-plugin-static-copy"
export default defineConfig({
publicDir: false,
build: {
lib: {
entry: resolve(__dirname, "src/index.ts"),
name: "kb-lib",
fileName: "index",
},
rollupOptions: {
external: ["react"],
output: {
globals: {
react: "React",
},
assetFileNames: "static/styles/components.css",
},
},
},
plugins: [
dts({
insertTypesEntry: true,
}),
viteStaticCopy({
targets: [
{
src: resolve(__dirname, "src/static"),
dest: "./",
},
{
src: resolve(__dirname, "./README.md"),
dest: "./",
rename: "README.md",
},
{
src: resolve(__dirname, "./package.json"),
dest: "./",
},
],
}),
],
})
Here are the extra folders/files it creates:
I wanna prevent the creation of .d.ts
files on storybook building.
Is there a way to prevent this behavior?
[UPDATED] I solved this removing dts
plugin and moving the definitions generation to the npm run tsc
script.
This way I decoupled d.ts generation from Vite and can have both working together.