DEPRECATION NOTE: since Webpack 5.20.0 you can use output.clean
option
A webpack plugin to remove obsolete chunk files in webpack watch mode. Especially useful when use hashes in output file names.
Via yarn:
yarn add webpack-clean-obsolete-chunks --dev
or via npm:
npm install webpack-clean-obsolete-chunks --save-dev
Just add this plugin as usual.
// webpack.config.js
var CleanObsoleteChunks = require('webpack-clean-obsolete-chunks');
module.exports = {
// ...
plugins: [
new CleanObsoleteChunks(options)
]
// ...
};
{
// Write logs to console.
// Default: true
verbose: true,
// Clean obsolete chunks of webpack child compilations.
// Default: false
deep: true
}
NOTE:
{deep: true}
option will work only if all descendent compilations of the initial compilation have unique names
Plugin searches for all updated chunks and deletes obsolete files in output directory after each webpack compilation.
We currently support Node.js of version ^6, ^7, ^8 and Webpack of version ^2, ^3, or ^4 (but ^1 should work also).
You're free to contribute to this project by submitting issues and/or pull requests. Please be sure to read the contribution guidelines before making changes for a pull request.
This project is licensed under MIT.