Skip to content

Instantly share code, notes, and snippets.

@jherax
Last active November 14, 2021 17:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jherax/458a2a271152bd05cb35c5845059f9df to your computer and use it in GitHub Desktop.
Save jherax/458a2a271152bd05cb35c5845059f9df to your computer and use it in GitHub Desktop.
Load multiple entries in webpack
var glob = require('glob');
module.exports = {
entry: toObject(glob.sync('assets/**/*.js*')),
output: {
filename: '[name].js'
},
//...
};
function toObject(paths) {
var names = {};
paths.forEach(function(path) {
// you can define entry names mapped to [name] here
names[path.split('/').slice(-1)[0]] = path;
});
return names;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment