Skip to content

jackypan1989/del-webpack-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Del-webpack-plugin

v2 was released, support webpack v5 !

A clean webpack plugin which can remove old files after bundling just as the well-known plugin clean-webpack-plugin, and more than it.

changelog

2021-04-01 (2.1.0): bump version, only use esbuild
2020-10-20 (2.0.0): rewrite to ts, rollup, and support webpack v5
2018-04-25 (1.0.5): upgrade to webpack v4
2018-05-28 (1.0.6): fix and update lib
2018-08-30 (1.1.0): add keepGeneratedAssets option
2018-10-18 (1.2.0): add allowExternal option

feature

  • webpack v5
  • typed source code
  • only delete after webpack compile
  • skip plugin if compile error
  • multiple entry / path support
  • include / exclude files support
  • verbose / mute info support
  • colorful log with chalk
  • example with webpack
  • support cross platform

install

# use yarn
yarn add -D del-webpack-plugin

# use npm
npm i -D del-webpack-plugin

usage (in your webpack config)

const DelWebpackPlugin = require('del-webpack-plugin')

{
  plugins: [
    new DelWebpackPlugin({
      include: ['**'],
      exclude: ['test.js'],
      info: true,
      keepGeneratedAssets: true,
      allowExternal: false
    })
  ]
}

options

field desc type default
info console.log added files and deleted files boolean true
keepGeneratedAssets keep webpack generated files boolean true
allowExternal allows del-webpack-plugin to delete files outside of webpack root folder boolean false
include a file list you wanna delete it will delete all files and folders by default, example: ['trash.js', 'trash/*.js'] string[] ['**']
exclude a file list you dont wanna delete, example: ['test.js', 'test/*.js'] string[] []

Welcome any issues and PRs submit :D