Skip to content

z-ti/vite-plugin-clean

Repository files navigation

vite-plugin-clean

npm

A Vite plugin to remove/clean your build files or folders before building.

Table of Contents

  1. Installation
  2. Usage
  3. Options
  4. Notes
  5. Issues
  6. License

Installation

You can install the plugin using npm or yarn:

npm i --save-dev vite-plugin-clean
yarn add --dev vite-plugin-clean

Usage

To use the plugin, add it to your Vite configuration file (vite.config.js or vite.config.ts). Here's an example:

vite.config.js

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

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

By default, the plugin will clean the dist directory before building.

Options

You can customize the plugin's behavior by passing a configuration object. The following options are available:

Name Type Default Description
targetFiles Array<string> | string ['dist'] List of files or directories to be removed before the build process starts.

Example Configuration

vite.config.js

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

export default defineConfig({
  plugins: [
    cleanPlugin({
      targetFiles: ['dist', 'test'] // Clean both 'dist' and 'test' directories
    })
  ]
})

Or, if you want to clean specific files:

vite.config.js

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

export default defineConfig({
  plugins: [
    cleanPlugin({
      targetFiles: ['bak.zip', 'test.js', 'demo.html'] // Clean specific files
    })
  ]
})

Notes

  • Vite Version Compatibility: This plugin is designed to work with the latest versions of Vite. Ensure you are using a recent version of Vite to avoid compatibility issues. If you encounter any problems, consider updating Vite to the latest version.
  • File Deletion: Be cautious when specifying files or directories in the targetFiles option. The plugin will permanently delete the specified files or folders before the build process.

Issues

If you encounter any issues or have suggestions for improvements, please click here Issue Report

License

MIT

Copyright (c) 2022-present flyfox

About

A vite plugin to remove/clean your build folder(s).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published