Registry / devops / webpack-clean-obsolete-chunks

webpack-clean-obsolete-chunks

JSON →
library0.4.0jsnpmunverified

A webpack plugin that removes obsolete chunk files during watch mode, particularly useful when using hashed output filenames. The current stable version is 0.4.0, released with irregular cadence. It supports webpack versions 2, 3, and 4, and Node.js versions 6, 7, 8. Key differentiators: it cleans files from child compilations with the 'deep' option and offers verbose logging. Unlike other clean plugins, it specifically targets chunks that are no longer emitted, preventing output directory bloat during development.

npm install webpack-clean-obsolete-chunks
INSTALL
IMPORT
SIG · WEBPACK-CLEAN-OBSO
W
webpack-clean-obsolete-chunks
devopsjavascriptv0.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export (CleanObsoleteChunks)
const CleanObsoleteChunks = require('webpack-clean-obsolete-chunks');
import CleanObsoleteChunks from 'webpack-clean-obsolete-chunks';
The package does not provide an ES module export; use CommonJS require. The default export is the plugin constructor.

Shows how to add the plugin to a webpack configuration with options. Assumes hashed filenames to see obsolete chunks being cleaned.

// webpack.config.js const CleanObsoleteChunks = require('webpack-clean-obsolete-chunks'); module.exports = { mode: 'development', entry: './src/index.js', output: { filename: '[name].[contenthash].js', path: __dirname + '/dist' }, plugins: [ new CleanObsoleteChunks({ verbose: true, deep: false }) ] };
Debug
Known issues
gotchaThe 'deep' option only works if child compilations have unique names.
fix
Ensure each child compilation has a unique name. Uniqueness is required for proper cleanup.
affects: >=0.3.0
gotchaPlugin may incorrectly delete files that are outside the current working directory (cwd). Fixed in v0.1.5.
fix
Update to v0.1.5 or later.
affects: <0.1.5
gotchaPlugin may not clean obsolete CSS files properly. Fixed in v0.1.8.
fix
Update to v0.1.8 or later.
affects: <0.1.8
gotchaBug with async code-splitting caused obsolete files not being cleaned. Fixed in v0.1.9.
fix
Update to v0.1.9 or later.
affects: <0.1.9
Errors
Common errors & fixes
Cannot find module 'webpack-clean-obsolete-chunks'
Module not installed or misspelled.
fix
Run 'npm install webpack-clean-obsolete-chunks --save-dev' and double-check the spelling.
CleanObsoleteChunks is not a constructor
Using ES6 import syntax with a package that exports as CommonJS.
fix
Use 'const CleanObsoleteChunks = require('webpack-clean-obsolete-chunks');' instead of import.
TypeError: Cannot read property 'options' of undefined
Plugin added without proper webpack instance or in invalid order.
fix
Ensure the plugin is added after the output configuration and within the plugins array.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
webpack-clean-obsolete-chunks — npm install webpack-clean-obsolete-chunks · libregistry