{"id":27543,"library":"webpack-clean-obsolete-chunks","title":"webpack-clean-obsolete-chunks","description":"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.","status":"active","version":"0.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/GProst/webpack-clean-obsolete-chunks","tags":["javascript","webpack","clean","remove","delete","old","obsolete","chunks","plugin"],"install":[{"cmd":"npm install webpack-clean-obsolete-chunks","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-clean-obsolete-chunks","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-clean-obsolete-chunks","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package does not provide an ES module export; use CommonJS require. The default export is the plugin constructor.","wrong":"import CleanObsoleteChunks from 'webpack-clean-obsolete-chunks';","symbol":"default export (CleanObsoleteChunks)","correct":"const CleanObsoleteChunks = require('webpack-clean-obsolete-chunks');"}],"quickstart":{"code":"// webpack.config.js\nconst CleanObsoleteChunks = require('webpack-clean-obsolete-chunks');\n\nmodule.exports = {\n  mode: 'development',\n  entry: './src/index.js',\n  output: {\n    filename: '[name].[contenthash].js',\n    path: __dirname + '/dist'\n  },\n  plugins: [\n    new CleanObsoleteChunks({\n      verbose: true,\n      deep: false\n    })\n  ]\n};","lang":"javascript","description":"Shows how to add the plugin to a webpack configuration with options. Assumes hashed filenames to see obsolete chunks being cleaned."},"warnings":[{"fix":"Ensure each child compilation has a unique name. Uniqueness is required for proper cleanup.","message":"The 'deep' option only works if child compilations have unique names.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"Update to v0.1.5 or later.","message":"Plugin may incorrectly delete files that are outside the current working directory (cwd). Fixed in v0.1.5.","severity":"gotcha","affected_versions":"<0.1.5"},{"fix":"Update to v0.1.8 or later.","message":"Plugin may not clean obsolete CSS files properly. Fixed in v0.1.8.","severity":"gotcha","affected_versions":"<0.1.8"},{"fix":"Update to v0.1.9 or later.","message":"Bug with async code-splitting caused obsolete files not being cleaned. Fixed in v0.1.9.","severity":"gotcha","affected_versions":"<0.1.9"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install webpack-clean-obsolete-chunks --save-dev' and double-check the spelling.","cause":"Module not installed or misspelled.","error":"Cannot find module 'webpack-clean-obsolete-chunks'"},{"fix":"Use 'const CleanObsoleteChunks = require('webpack-clean-obsolete-chunks');' instead of import.","cause":"Using ES6 import syntax with a package that exports as CommonJS.","error":"CleanObsoleteChunks is not a constructor"},{"fix":"Ensure the plugin is added after the output configuration and within the plugins array.","cause":"Plugin added without proper webpack instance or in invalid order.","error":"TypeError: Cannot read property 'options' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}