Skip to content

Creating type definitions (d.ts) for a vue JS component library #11455

Discussion options

You must be logged in to vote

Sorry I just saw this after a week. In detail, you can make your library by vite-plugin-dts(for types) and Vite:

pnpm create vue

In the project folder, make your components, and export it in a entry file like index.ts:

// If you have lots of components to export, maybe use a Nodejs script to generate the file

export { default as Button } from './Button.vue'
// ...

Install vite-plugin-dts:

pnpm i -D vite-plugin-dts

Create a file called tsconfig.build.json in the root:

{
  "extends": "./tsconfig.app.json",
}

tsconfig.app.json should be generated automatically when you use pnpm create vue.

In vite.config.ts:

// Basic config

import { defineConfig } from 'vite'
import vue from '@vitejs/plugi…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@guilherme-gm
Comment options

Comment options

You must be logged in to vote
1 reply
@guilherme-gm
Comment options

Answer selected by guilherme-gm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants