Best way to have all files in a directory be entry points in webpack?
<p>I want to create multiple entry points for a website, which is pretty easily done in Webpack using an object for the <code>entry</code> property, like <a href="https://github.com/webpack/webpack/tree/master/examples/multiple-entry-points" rel="noreferrer">here</a>.</p>

<p>But as the site grows (and it inevitably will) having to add each entry point seems cumbersome and prone to error. So I'd like to simply point at a directory and say "here are all the entry points."</p>

<p>So I've cooked this up:</p>

<pre><code>var path = require('path');
var fs = require('fs');
var entryDir = path.resolve(__dirname, '../source/js');
var entries = fs.readdirSync(entryDir);
var entryMap = {};
entries.forEach(function(entry){
    var stat = fs.statSync(entryDir + '/' + entry);
    if (stat &amp;&amp; !stat.isDirectory()) {
        var name = entry.substr(0, entry.length -1);
        entryMap[name] = entryDir + '/' + entry;
    }
});

module.exports = {
  entry: entryMap,
  output: {
    path: path.resolve(__dirname, '../static/js'),
    filename: "[name]"
  },
...
</code></pre>

<p>This works fine, but is there a feature or configuration option in Webpack that would handle this for me?</p>