Skip to content

Instantly share code, notes, and snippets.

@sirlancelot
Last active August 29, 2015 14:09
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 sirlancelot/944888423c279f61c011 to your computer and use it in GitHub Desktop.
Save sirlancelot/944888423c279f61c011 to your computer and use it in GitHub Desktop.
module.exports = AddCustomCodePlugin
function AddCustomCodePlugin() {}
AddCustomCodePlugin.prototype.apply = function(compiler) {
var self = this
compiler.plugin("compilation", function(compilation) {
compilation.mainTemplate.plugin("local-vars", self.localVars.bind(self)))
})
}
AddCustomCodePlugin.prototype.localVars = function(source, chunk) {
return source + [
"// Add your javascript code here.",
"console.log('inside webpack bootstrap');"
].join("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment