Skip to content

Instantly share code, notes, and snippets.

@jantimon
Created May 29, 2016 08:43
Show Gist options
  • Save jantimon/2d1a05e6740c27b03b24091a8aec420d to your computer and use it in GitHub Desktop.
Save jantimon/2d1a05e6740c27b03b24091a8aec420d to your computer and use it in GitHub Desktop.
Inject a file into the main compilation
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