webpack-entry-plus

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

Generate dynamic webpack bundle output names from wildcarded entry files using an array of entry/output definitions. Version 1.0.19 is the latest release; the package is stable but infrequently updated. It supports both string and function-based output name transformations, and integrates with glob for wildcard matching. Unlike manual entry configuration, it avoids hardcoding bundle names, which is useful for CMS or multi-page architectures. Requires webpack 4+ and works with Node.js. No breaking changes since initial release, but it is not actively maintained.

error Cannot find module 'webpack-entry-plus'
cause Missing install or incorrect import path.
fix
Install: npm install --save-dev webpack-entry-plus, then use require('webpack-entry-plus')
error TypeError: entryPlus is not a function
cause Incorrect import: using default import with ES module syntax or destructuring.
fix
Use const entryPlus = require('webpack-entry-plus');
error Error: The 'entry' option must be an object, function, or string
cause Passing an invalid entry object, typically because outputName is not a string or function.
fix
Ensure each item in the array has a outputName that is either a string or a function returning a string.
error Module not found: Error: Can't resolve 'glob'
cause Glob is not installed, but it is required only if you use glob.sync in your config.
fix
Install glob: npm install --save-dev glob
gotcha Package exposes only one function. Ensure you are requiring correctly as default.
fix Use const entryPlus = require('webpack-entry-plus');
gotcha The entryFiles array must contain file paths relative to your webpack context or absolute paths. Glob patterns from glob.sync() return relative paths which may need adjustment.
fix Resolve paths relative to webpack's context or use absolute paths with glob.sync(..., { cwd: ... })
gotcha When using a function for outputName, it must return a string that will be used as the [name] in output. The function receives the full file path; ensure replacements produce valid filenames.
fix Return a string that does not contain path separators (use replace to strip directories).
gotcha If outputName is a string, all entryFiles will be bundled into a single output chunk. This may not be intended if you want separate bundles.
fix Use a function for outputName when you need separate bundles per entry file.
gotcha The package does not support webpack 5's new entry descriptor syntax (e.g., { import, dependOn }). Only an array of strings is accepted per entryFiles item.
fix Use webpack's native entry configuration or another plugin if you need advanced entry features.
gotcha No type definitions provided. TypeScript users need to create a custom declaration file.
fix Add a .d.ts file: declare module 'webpack-entry-plus' { const entryPlus: (entries: EntryItem[]) => any; export default entryPlus; }
gotcha The package uses require('glob') internally if not passed? No, it expects you to pass glob results. You must install glob separately.
fix npm install --save-dev glob
npm install webpack-entry-plus
yarn add webpack-entry-plus
pnpm add webpack-entry-plus

Shows how to configure webpack with dynamic entry names using glob patterns and a function for output name transformation.

// webpack.config.js
const path = require('path');
const entryPlus = require('webpack-entry-plus');
const glob = require('glob');

const entryItems = [
  {
    entryFiles: ['file1.js'],
    outputName: 'bundle1'
  },
  {
    entryFiles: glob.sync('./pages/*.js'),
    outputName(item) {
      return item.replace('.js', '').replace(/^.*[\\/]/, '');
    }
  }
];

module.exports = {
  entry: entryPlus(entryItems),
  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, 'dist')
  }
};