Skip to content

oyjt/vite-plugin-clean-build

Repository files navigation

vite-plugin-clean-build

npm license

A vite plugin for remove/clean files after build.

English | 中文

Table of Contents

  1. Installation
  2. Usage
  3. Issues
  4. License

Installation

  # npm
  npm i vite-plugin-clean-build -D

  # yarn
  yarn add vite-plugin-clean-build -D

  # pnpm
  pnpm add vite-plugin-clean-build -D

Usage

Here's an example vite config illustrating how to use this plugin

vite.config.js

import CleanBuild from 'vite-plugin-clean-build';
export default {
  plugins: [CleanBuild()],
}

Options

You can pass a hash of configuration options to vite-plugin-clean-build. Allowed values are as follows:

Name Type Default Description
outputDir {string} 'dist' Removes files in the directory
patterns {Array<string>} [] Removes files after every build that match this pattern
verbose {boolean} false Write logs to console

Here's an example vite config illustrating how to use these options

vite.config.js

import CleanBuild from 'vite-plugin-clean-build';
export default {
  plugins: [CleanBuild(
    {
      outputDir: 'dist',
      patterns: [
        'images/**',
        '!images/logo.png'
      ],
      verbose: true,
    }
  )],
}

Issues

If you encounter some problems during use, please click here Issue Report

License

MIT License

Copyright (c) 2023-present cnpath