Skip to content

Instantly share code, notes, and snippets.

@drFabio
Created June 29, 2016 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drFabio/8df47f550bfb82f143bccad6a62c37a3 to your computer and use it in GitHub Desktop.
Save drFabio/8df47f550bfb82f143bccad6a62c37a3 to your computer and use it in GitHub Desktop.
MyPlugin.prototype.apply = function(compiler) {
compiler.plugin("entry-option", function(context, entry) {
function itemToPlugin(item, name) {
if(Array.isArray(item))
return new MultiEntryPlugin(context, item, name);
else
return new SingleEntryPlugin(context, item, name);
}
compiler.apply(itemToPlugin(entry,'main'));
compiler.apply(itemToPlugin(__dirname+'/someFile.md','target/name'));
// if(typeof entry=== 'string'){
// entry = [entry,__dirname+'/test.md']
// }
// else if (Array.isArray(entry)){
// entry.push(__dirname+'/test.md')
// }
// else{
// entry['opa'] = __dirname+'/test.md'
// }
// if( Array.isArray(entry)) {
// compiler.apply(itemToPlugin(entry, "main"));
// } else if(typeof entry === "object") {
// Object.keys(entry).forEach(function(name) {
// compiler.apply(itemToPlugin(entry[name], name));
// });
// }
return true;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment