webpack-entries

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

Utility to generate webpack entry points from glob patterns. Current stable version is 1.0.0, released with low frequency. Converts glob matches into arrays or objects (keyed by file name or relative path) suitable for webpack's entry configuration. No dependencies. Lightweight alternative to manual entry definition.

error Cannot find module 'webpack-entries'
cause Package not installed or installed as --save-dev not --save
fix
Run: npm install webpack-entries --save-dev
error entries is not a function
cause Incorrect import style (e.g., import entries from 'webpack-entries' in ESM context)
fix
Use const entries = require('webpack-entries'); or const { default: entries } = await import('webpack-entries');
gotcha File names without extension are used as keys (e.g., 'a' from 'a.js'); duplicates overwrite previous entries.
fix Ensure glob pattern yields unique base file names or use nested patterns with /**/ to include path in keys.
gotcha The function throws synchronously if glob pattern matches no files; no graceful error handling.
fix Wrap call in try-catch or ensure pattern matches at least one file.
gotcha Only supports CommonJS require; no ES module or TypeScript support.
fix Use dynamic import or CommonJS require in an ES module context: const entries = await import('webpack-entries').then(m => m.default);
npm install webpack-entries
yarn add webpack-entries
pnpm add webpack-entries

Shows how to require webpack-entries and use it in a webpack config to generate entry points from a glob pattern, producing an object with file name keys.

var entries = require('webpack-entries');
var path = require('path');

module.exports = {
  entry: entries('./src/js/*.js', true),
  output: {
    filename: '[name].bundle.js',
    path: path.resolve(__dirname, 'dist')
  }
};