Add support for webpack.BannerPlugin
This commit is contained in:
parent
6eb2d31c18
commit
fcecadb5ee
12
index.js
12
index.js
|
|
@ -185,8 +185,16 @@ HtmlWebpackPlugin.prototype.evaluateCompilationResult = function(compilation, co
|
|||
if(!compilationResult) {
|
||||
return Promise.reject('The child compilation didn\'t provide a result');
|
||||
}
|
||||
// Strip the leading 'var '
|
||||
var source = compilationResult.source().substr(3);
|
||||
var source = compilationResult.source();
|
||||
// Strip the leading 'var ' if present.
|
||||
// If webpack.BannerPlugin is used, `source` starts with given comment.
|
||||
if (_.startsWith(source, 'var')) {
|
||||
source = source.substr(3);
|
||||
} else {
|
||||
// Replace first matching result variable, so that only a function is left.
|
||||
source = source.replace('var result =', '');
|
||||
}
|
||||
|
||||
// Evaluate code and cast to string
|
||||
var newSource;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -627,6 +627,20 @@ describe('HtmlWebpackPlugin', function() {
|
|||
}, ['<html lang="en" manifest="foo.appcache">'], null, done);
|
||||
});
|
||||
|
||||
it('works with webpack bannerplugin', function(done) {
|
||||
testHtmlPlugin({
|
||||
entry: path.join(__dirname, 'fixtures/index.js'),
|
||||
output: {
|
||||
path: OUTPUT_DIR,
|
||||
filename: 'index_bundle.js'
|
||||
},
|
||||
plugins: [
|
||||
new webpack.BannerPlugin('Copyright and such.'),
|
||||
new HtmlWebpackPlugin()
|
||||
]
|
||||
}, ['<html'], null, done);
|
||||
});
|
||||
|
||||
it('shows an error when a template fails to load', function(done) {
|
||||
testHtmlPlugin({
|
||||
entry: path.join(__dirname, 'fixtures/index.js'),
|
||||
|
|
|
|||
Loading…
Reference in New Issue