HardSourceWebpackPlugin is a webpack plugin that provides intermediate caching of module compilation results to disk, drastically speeding up subsequent builds (second build is significantly faster). Version 0.13.1 is the latest stable release, last updated in 2020. It works by caching the output of webpack's module resolution and transformation steps, using a configurable cache directory and hash-based invalidation. Key differentiators: it caches at the module level (not just the entire bundle), supports parallel builds via ParallelModulePlugin, and allows excluding specific modules. However, it is no longer maintained and may have compatibility issues with modern webpack versions (5+), making it less suitable for new projects compared to persistent caching built into webpack 5.
npm install hard-source-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Shows basic webpack configuration with HardSourceWebpackPlugin for caching modules to disk.
Use webpack 5's built-in persistent caching (cache: { type: 'filesystem' }) instead. For webpack 4, consider using babel-loader's cacheDirectory or other caching strategies.Use ExcludeModulePlugin to exclude problematic loaders, or switch to webpack 5 persistent cache.
Delete the cache directory or use the configHash and environmentHash options to ensure cache invalidation.
Use const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');Avoid using ParallelModulePlugin with dev server; consider using webpack's built-in parallelism (webpack 5) or thread-loader.
Run npm install --save-dev hard-source-webpack-plugin and ensure the require path is correct.
Change import HardSourceWebpackPlugin from ... to const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');Downgrade webpack to version 4, or migrate to webpack 5 persistent cache.
Add ExcludeModulePlugin to exclude mini-css-extract-loader paths. Example: new HardSourceWebpackPlugin.ExcludeModulePlugin([{ test: /mini-css-extract-plugin[\\/]dist[\\/]loader/ }])