Created
May 29, 2016 08:43
-
-
Save jantimon/2d1a05e6740c27b03b24091a8aec420d to your computer and use it in GitHub Desktop.
Inject a file into the main compilation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.apply = function(compiler) { | |
var SingleEntryPlugin = require ('webpack/lib/SingleEntryPlugin'); | |
var styleguideName = 'atrium-styleguide-core'; | |
var styleguideEntry = 'atrium-entry.js'; | |
var styleguideFileName = 'atrium/core.js'; | |
// Inject entry into the main compilation | |
compiler.apply(new SingleEntryPlugin( | |
this.context, | |
__dirname + '/' + styleguideEntry, | |
styleguideName | |
)); | |
// Output configuration of the injected entry | |
compiler.plugin('compilation', function(compilation) { | |
compilation | |
.mainTemplate | |
.plugin('asset-path', function(name, data) { | |
return (data.chunk && data.chunk.name === styleguideName) ? styleguideFileName : name; | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment