Webpack Watched Glob Entries Plugin

raw JSON →
3.2.0 verified Sat Apr 25 auth: no javascript

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.

error Cannot find module 'webpack-watched-glob-entries-plugin'
cause Package not installed or incorrectly imported in ESM project.
fix
Install the package: npm install --save-dev webpack-watched-glob-entries-plugin. If using ESM, use createRequire or dynamic import.
error TypeError: WebpackWatchedGlobEntries.getEntries is not a function
cause Trying to call getEntries on an instance instead of the class.
fix
Use WebpackWatchedGlobEntries.getEntries (static method), not new WebpackWatchedGlobEntries().getEntries.
error HookWebpackError: Plugin tried to register a hook that is already registered
cause Multiple instances of the plugin added to webpack config.
fix
Ensure only one instance of new WebpackWatchedGlobEntries() is in the plugins array.
error Error: You must provide at least one glob pattern
cause Empty array passed to getEntries or no patterns provided.
fix
Pass an array with at least one glob string to getEntries().
breaking Dropped support for Node.js <18 in v3.0.0. Older versions (2.x) support Node 10 and 12.
fix Upgrade to Node.js >=18 or continue using v2.x if you need older Node support.
breaking v3.0.0 dropped support for Node 12 and added support for Node 20 and 21. Requires webpack 5.
fix Use webpack 5 and Node >=18.
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).
fix For rename detection, ensure you are using webpack's watch mode and the plugin is instantiated.
deprecated Using webpack 4 may be deprecated in future versions; current versions require webpack 5.
fix Upgrade to webpack 5 if still on webpack 4 and using v3+.
gotcha The plugin does not support ESM imports. It is a CommonJS package only.
fix Use require() or configure your bundler to handle CommonJS modules.
npm install webpack-watched-glob-entries-plugin
yarn add webpack-watched-glob-entries-plugin
pnpm add webpack-watched-glob-entries-plugin

Shows typical webpack config using the plugin to glob for entry files, ignore tests, and enable watch mode.

// 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'
};