Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

vite-plugin-dts-bundle-generator

f-lawe377MIT2.1.0TypeScript support: included

DTS bundle generator for Vite

vite-plugin, dts, bundle, typescript

readme

DTS Bundle Generator Vite plugin

Versions Downloads Licence GitHub Actions

Ever wanted to easily package your typescript library with a bundled declaration file? Integrate DTS Bundle Generator within Vite!

Installation

npm i --save-dev vite-plugin-dts-bundle-generator
yarn add --dev vite-plugin-dts-bundle-generator

Usage

Add this block to your vite.config.ts:

import path from 'path';
import { defineConfig, normalizePath } from 'vite';
import dtsBundleGenerator from 'vite-plugin-dts-bundle-generator';

export default defineConfig({
  plugins: [
    dtsBundleGenerator({
      fileName: 'my-lib.d.ts',
      output: {
        // output config
      },
      libraries: {
        // libraries config
      }
    }, {
      // compilation options
    })
  ],
  build: {
    lib: {
      entry: normalizePath(path.resolve('src', 'index.ts')),
      formats: ['es'],
      fileName: 'my-lib.mjs'
    }
  }
});

And that's it!

Configuration

This library handle both single and multiple entrypoints. You can use any of the output, libraries and compilation options available in the config file of DTS Bundle Generator.