Webpack plugin that watches additional files and triggers a rebuild when those files change. Version 1.2.1 is the latest stable release, with no recent updates. It supports webpack 3, 4, and 5. Unlike webpack's built-in watch machinery, this plugin allows watching glob patterns outside the compilation context (e.g., configuration files, data files). It works with live-reload but not HMR. The plugin is simple: accepts an array of file patterns (with negation support) and an optional verbose flag to log matched files. It has no dependencies beyond webpack.
npm install webpack-watch-files-pluginVerified import paths — ran on the pinned version, not inferred.
Shows how to import and configure the plugin to watch CSS and HTML files outside the compilation.
Use the same pattern format as webpack's resolve.alias or CopyWebpackPlugin. For negation, add '!./src/*.test.js' alongside './src/**/*.js'.
Use webpack's built-in watch or other HMR-compatible solutions if you need partial updates.
Enable verbose: true to see which files are being watched.
Use relative paths like './src/**/*.js' not '/absolute/path/src/**/*.js'.
Use require('webpack-watch-files-plugin').default instead of require('webpack-watch-files-plugin').Run npm install --save-dev webpack-watch-files-plugin.
Ensure options includes { files: [...], verbose: false }.