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.
Common errors
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');
Warnings
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);
Install
npm install webpack-entries yarn add webpack-entries pnpm add webpack-entries Imports
- default wrong
import entries from 'webpack-entries';correctvar entries = require('webpack-entries'); - entries function wrong
entries('./src/js/*.js'); // omitting second argument returns array, not objectcorrectentries('./src/js/*.js', true); - object with nested keys wrong
entries('./src/**/*.js', false); // returns flat array, losing directory structurecorrectentries('./src/**/*.js', true);
Quickstart
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')
}
};