Skip to content

Commit

Permalink
readme updates
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisblossom committed Mar 4, 2019
1 parent d2ac516 commit bdb5099
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
20 changes: 18 additions & 2 deletions README.md
Expand Up @@ -19,6 +19,12 @@

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

> NOTE: Node v6+ and Webpack v2+ are supported and tested.
## About

By default, this plugin will remove all files inside webpack's `output.path` directory, as well as all unused webpack assets after every successful rebuild.

## Installation

`npm install --save-dev clean-webpack-plugin`
Expand All @@ -38,7 +44,7 @@ const webpackConfig = {
module.exports = webpackConfig;
```

### Options and Defaults (Optional)
## Options and Defaults (Optional)

```js
new CleanWebpackPlugin({
Expand Down Expand Up @@ -75,6 +81,7 @@ new CleanWebpackPlugin({

/**
* Removes files once prior to Webpack compilation
* Not included in rebuilds (watch mode)
*
* NOTE: customPatterns are included with this
*
Expand All @@ -88,7 +95,7 @@ new CleanWebpackPlugin({
/**
* Custom pattern matching
*
* Removes files on after every build (watch mode) that match this pattern.
* Removes files after every build (including watch mode) that match this pattern.
* Used for files that are not created directly by Webpack.
*
* Use !negative patterns to exclude files
Expand All @@ -105,6 +112,7 @@ new CleanWebpackPlugin({
* default: false
*/
dangerouslyAllowCleanPatternsOutsideProject: true,
dry: true,
});
```

Expand All @@ -116,9 +124,17 @@ This is a modified version of [WebPack's Plugin documentation](https://webpack.j
const CleanWebpackPlugin = require('clean-webpack-plugin'); // installed via npm
const HtmlWebpackPlugin = require('html-webpack-plugin'); // installed via npm
const webpack = require('webpack'); // to access built-in plugins
const path = require('path');

module.exports = {
entry: './path/to/my/entry/file.js',
output: {
/**
* With zero configuration,
* clean-webpack-plugin will remove files inside the directory below
*/
path: path.resolve(process.cwd(), 'dist'),
},
module: {
rules: [
{
Expand Down
29 changes: 22 additions & 7 deletions src/clean-webpack-plugin.ts
Expand Up @@ -5,34 +5,49 @@ import del from 'del';
interface Options {
/**
* Simulate the removal of files
*
* default: false
*/
dry: boolean;

/**
* console.warn removed files
* Write Logs to Console
* (Always enabled when dry is true)
*
* default: false
*/
verbose: boolean;

/**
* File patterns to files after webpack has been successfully ran
* Custom pattern matching
*
* Removes files after every build (including watch mode) that match this pattern.
* Used for files that are not created directly by Webpack.
*
* use !negative patterns to exclude files
* Use !negative patterns to exclude files
*
* See https://github.com/sindresorhus/del#patterns
* default: disabled
*/
customPatterns: string[];

/**
* Remove files once prior to compilation
* Removes files once prior to Webpack compilation
* Not included in rebuilds (watch mode)
*
* use !negative patterns to exclude files
* NOTE: customPatterns are included with this
*
* See https://github.com/sindresorhus/del#patterns
* Use !negative patterns to exclude files
*
* default: ['**']
*/
initialPatterns: string[];

/**
* Allow clean patterns outside of process.cwd()
*
* requires dry option to be explicitly set
*
* default: false
*/
dangerouslyAllowCleanPatternsOutsideProject: boolean;
}
Expand Down

0 comments on commit bdb5099

Please sign in to comment.