In my TypeScript project, I am utilizing the tsup build tool for bundling. I have a requirement to specify all the folders and files within the components
directory to the root dist
folder.
src/
components/
card/
card.tsx
index.ts
carousel/
carousel.tsx
index.ts
...other components...
index.ts
Currently, the output directory I am getting is structured like this:
dist/
components
card
card.d.ts
card.js
index.d.ts
index.js
carousel
carousel.d.ts
carousel.js
index.d.ts
index.js
...
However, for better clarity in importing (tree-shaking), I aim to relocate all my components from the components folder directly into the dist
directory as shown below:
dist/
card
card.d.ts
card.js
index.d.ts
index.js
carousel
carousel.d.ts
carousel.js
index.d.ts
index.js
...
Below is the configuration in my tsup
file:
export default defineConfig((options: Options) => ({
treeshake: true,
splitting: true,
entry: ['src/**/*.{ts,tsx}'],
format: ['cjs', 'esm'],
dts: true,
...options,
}));