webpack-glob

raw JSON →
2.0.2 verified Sat Apr 25 auth: no javascript maintenance

A tool that combines webpack with glob patterns, allowing you to specify multiple webpack configuration files using minimatch/wildcard patterns. Version 2.0.2 is the latest stable release, though development has been sparse since 2016. It provides both CLI and programmatic (Node.js) APIs for compiling glob-matched webpack configs. Differentiates itself by enabling multi-config webpack setups without manual file listing.

error Error: Cannot find module 'webpack'
cause webpack is not installed as a peer dependency.
fix
npm install webpack --save-dev
error TypeError: WebpackGlob is not a constructor
cause Using ES6 import incorrectly, or destructuring the require result.
fix
Use const WebpackGlob = require('webpack-glob');
gotcha The package only supports CommonJS; ES module imports will fail. Use require() or configure bundler for CommonJS interop.
fix Switch to require() or use bundler transform for CommonJS.
deprecated The closestWatch option was removed in v2.0.0 and no longer works.
fix Use watch mode via compilerOptions.watch instead.
gotcha If no matching config files are found, webpack-glob may hang or not error. Ensure glob pattern is correct.
fix Verify glob pattern. Use --config with quotes in CLI or escape properly.
npm install webpack-glob
yarn add webpack-glob
pnpm add webpack-glob

Creates a WebpackGlob instance with default options and compiles all webpack config files matching the glob pattern.

var WebpackGlob = require('webpack-glob');
var webpackOptions = {
  output: { path: './dist' },
  stats: { colors: true }
};
var compilerOptions = {
  progress: true,
  json: false,
  memoryFs: false
};
var webpack = new WebpackGlob(compilerOptions, webpackOptions);
webpack.run('./src/**/webpack.config.js').then(function() {
  console.log('done');
}).catch(function(err) {
  console.error(err);
});