vite-plugin-clean
v2.0.1
Published
A vite plugin to remove/clean your build file(s) or folder(s).
Downloads
9,895
Maintainers
Readme
vite-plugin-clean
A Vite plugin to remove/clean your build files or folders before building.
Table of Contents
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
Copyright (c) 2022-present flyfox