Webpack Watched Glob Entries Plugin
raw JSON →Webpack plugin (v3.2.0) that allows you to use glob patterns to define entry points and automatically watches those glob matches for changes during development. It integrates with webpack's watch mode so that adding or removing files matching the glob triggers a rebuild without manual configuration. Supports multiple glob patterns, custom glob options like ignore patterns, and preserves directory structure in output names. Requires Node >=18 and webpack 5. Unlike manual entry arrays, this plugin dynamically updates entries as files change, making it ideal for projects with many entry points or those that frequently add/remove source files. Released relatively infrequently, with maintenance focused on dependency updates and Node version support.
Common errors
error Cannot find module 'webpack-watched-glob-entries-plugin' ↓
error TypeError: WebpackWatchedGlobEntries.getEntries is not a function ↓
error HookWebpackError: Plugin tried to register a hook that is already registered ↓
error Error: You must provide at least one glob pattern ↓
Warnings
breaking Dropped support for Node.js <18 in v3.0.0. Older versions (2.x) support Node 10 and 12. ↓
breaking v3.0.0 dropped support for Node 12 and added support for Node 20 and 21. Requires webpack 5. ↓
gotcha The getEntries method uses glob.sync() under the hood, so changes to the filesystem (addition/removal of files) will be detected during watch mode, but not if a file is renamed (unless you add/remove). ↓
deprecated Using webpack 4 may be deprecated in future versions; current versions require webpack 5. ↓
gotcha The plugin does not support ESM imports. It is a CommonJS package only. ↓
Install
npm install webpack-watched-glob-entries-plugin yarn add webpack-watched-glob-entries-plugin pnpm add webpack-watched-glob-entries-plugin Imports
- WebpackWatchedGlobEntries wrong
import WebpackWatchedGlobEntries from 'webpack-watched-glob-entries-plugin';correctconst WebpackWatchedGlobEntries = require('webpack-watched-glob-entries-plugin'); - getEntries wrong
new WebpackWatchedGlobEntries().getEntries()correctWebpackWatchedGlobEntries.getEntries(globs, options) - WebpackWatchedGlobEntries (as plugin) wrong
plugins: [WebpackWatchedGlobEntries]correctplugins: [new WebpackWatchedGlobEntries()]
Quickstart
// webpack.config.js
const path = require('path');
const WebpackWatchedGlobEntries = require('webpack-watched-glob-entries-plugin');
module.exports = {
entry: WebpackWatchedGlobEntries.getEntries(
[
path.resolve(__dirname, 'src/entries/**/*.js'),
path.resolve(__dirname, 'src/pages/**/*.js')
],
{ ignore: '**/*.test.js' }
),
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js'
},
plugins: [
new WebpackWatchedGlobEntries()
],
mode: 'development'
};