Skip to content

Files

Latest commit

ef637eb · Jul 24, 2024

History

History
48 lines (42 loc) · 762 Bytes

README.md

File metadata and controls

48 lines (42 loc) · 762 Bytes

Introduce

用于构建前清理上次构建的产物

Install

pnpm install vite-plugin-clean -D

Usage

import { defineConfig } from 'vite'
import vitePluginClean from 'vite-plugin-clean'

export default defineConfig({
  plugins: [
    vitePluginClean()
  ]
})

API

options

export type PluginOptions = {
  folder: string | string[]
  hooks?: {
    buildStart?: () => void | Promise<void>
    closeBundle?: () => void | Promise<void>
  }
}

example

export default defineConfig({
  plugins: [
    vitePluginClean({
        folder: 'dist', // default: dist or ['dist'] or ['dist', 'lib']
        hooks: {
          buildStart() {
            console.log('build start')
          }
        }
    })
  ]
})