https://github.com/allexcd/webpack-clean
A webpack plugin to clean specified files after build
https://github.com/allexcd/webpack-clean
webpack-plugin
Last synced: about 1 year ago
JSON representation
A webpack plugin to clean specified files after build
- Host: GitHub
- URL: https://github.com/allexcd/webpack-clean
- Owner: allexcd
- License: mit
- Created: 2015-09-07T14:39:31.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2022-06-12T14:10:20.000Z (about 4 years ago)
- Last Synced: 2025-05-18T04:14:39.055Z (about 1 year ago)
- Topics: webpack-plugin
- Language: JavaScript
- Size: 618 KB
- Stars: 10
- Watchers: 5
- Forks: 7
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/allexcd/webpack-clean/stargazers)
[](https://github.com/allexcd/webpack-clean/network)
[](https://github.com/allexcd/webpack-clean/issues)
[](https://github.com/allexcd/webpack-clean/issues?q=is%3Aissue+is%3Aclosed)
[](https://github.com/allexcd/webpack-clean/releases)
[](https://github.com/allexcd/webpack-clean/releases)
[](https://nodei.co/npm/webpack-clean)
[](https://www.npmjs.com/package/webpack-clean)
[](https://nodei.co/npm/webpack-clean)
[](https://www.npmjs.com/package/webpack-clean)
[](https://www.npmjs.com/package/webpack-clean)
[](https://github.com/allexcd/webpack-clean/blob/master/LICENSE)
##### CI Status:
[]( https%3A%2F%2Fg.codefresh.io%2Fpublic%2Faccounts%2Fallexcd_marketplace%2Fpipelines%2F5ea80cd06a6a4c392b40b192)
## Webpack Clean
A webpack plugin to clean specified files after build
### Getting started
Install the plugin:
```
npm install webpack-clean --save-dev
yarn add webpack-clean --dev
```
### API
```javascript
new WebpackCleanPlugin(files: array|string, [ { [basePath: string], [removeMaps: boolean] } ])
```
* `files` - array of files or string for a single file relative to the `basePath` or to the `context` of your config (if the `basePath` param is not specified),
* `basePath` (optional) - string - directory to be resolved to
* `removeMaps` (optional) - boolean - specify if the `.map` files should be automatically removed. Disabled by default.
* `forceDelete` (optional) - boolean - specify if the files should be force deleted in case of compile errors. If `forceDelete` is not enabled, the compile errors will be logged to `stdout` but the deletion of the files will not take place. Disabled by default.
### Usage
```javascript
var WebpackCleanPlugin = require('webpack-clean');
module.exports = {
context: path.join(__dirname, './'),
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
plugins: [
new WebpackCleanPlugin([
'dist/test1.js',
'dist/test2.js'
])
]
};
module.exports = {
plugins: [
new WebpackCleanPlugin(
'dist/fileA.js',
{basePath: path.join(__dirname, './')}
)
]
};
module.exports = {
plugins: [
new WebpackCleanPlugin([
'fileA.js',
'fileB.js'
], {basePath: path.join(__dirname, 'dist'))}
]
};
module.exports = {
plugins: [
new WebpackCleanPlugin([
'fileA.js',
'fileB.js'
], {basePath: path.join(__dirname, 'dist'), removeMaps: true)}
]
};
module.exports = {
plugins: [
new WebpackCleanPlugin([
'fileA.js',
'fileB.js'
], {basePath: path.join(__dirname, 'dist'), removeMaps: true, forceDelete: true)}
]
};
```