vite-plugin-lib
TypeScript icon, indicating that this package has built-in type declarations

2.0.11 • Public • Published

vite-plugin-lib

Vite plugin for build configuration, automatic aliases, and type declarations.

npm

Features

  • Automatic aliases based on tsconfig.json
  • Automatic build configuration
  • Type declaration generation based on vite-plugin-dts.

Installation

yarn add -D vite-plugin-lib

Usage

This highly opinionated all-in one Vite plugin enables automatic alias configuration based on tsconfig.json paths, library export configuration, and type declaration generation.

Aliases

import { defineConfig } from 'vite'
import { tsconfigPaths } from 'vite-plugin-lib'

export default defineConfig({
  plugins: [tsconfigPaths()],
})

Library

The library plugin includes the alias plugin, configures build settings, and generates .d.ts files.

import { defineConfig } from 'vite'
import { library } from 'vite-plugin-lib'

export default defineConfig({
  plugins: [
    library({
      entry: 'src/index.ts', // file name determines output file names, default is 'src/index.ts'
      formats: ['es'], // optional, default is ['es']
      name: 'YourGlobalUMDName', // optional if format does not include 'umd' or 'iife'
      external: ['some-package'], // optional, default is all node_modules and builtin modules
      manifest: 'package.json', // relative path to package.json, default is package.json
    }),
  ],
})

Package Sidebar

Install

npm i vite-plugin-lib

Weekly Downloads

320

Version

2.0.11

License

MIT

Unpacked Size

15.2 kB

Total Files

6

Last publish

Collaborators

  • yeger