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

Package detail

vite-plugin-lib

DerYeger716MIT2.1.4TypeScript support: included

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

vite-plugin, declarations, library, aliases

readme

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
    }),
  ],
})