[async] make sure the async chunks aren't included in the html

This commit is contained in:
Olivier Tassinari 2015-06-15 20:19:12 +01:00
parent 1f5b357159
commit 0d727cc23e
4 changed files with 16 additions and 2 deletions

View File

@ -206,6 +206,11 @@ HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function(compilation, webp
var chunk = chunks[i];
var chunkName = chunk.names[0];
// This chunk doesn't have a name. This script can't handled it.
if(chunkName === undefined) {
continue;
}
// Skip if the chunks should be filtered and the given chunk was not added explicity
if (Array.isArray(includedChunks) && includedChunks.indexOf(chunkName) === -1) {
continue;

View File

@ -23,8 +23,9 @@ function testHtmlPlugin(webpackConfig, expectedResults, outputFile, done, expect
expect(compilationWarnings).not.toBe('');
} else {
expect(compilationWarnings).toBe('');
}
}
var htmlContent = fs.readFileSync(path.join(OUTPUT_DIR, outputFile)).toString();
for (var i = 0; i < expectedResults.length; i++) {
var expectedResult = expectedResults[i];
if (expectedResult instanceof RegExp) {
@ -50,7 +51,7 @@ describe('HtmlWebpackPlugin', function() {
filename: 'index_bundle.js'
},
plugins: [new HtmlWebpackPlugin()]
}, ['<script src="index_bundle.js"'], null, done);
}, [/<body>[\s]*<script src="index_bundle.js"><\/script>[\s]*<\/body>/], null, done);
});

1
spec/fixtures/async.js vendored Normal file
View File

@ -0,0 +1 @@
module.exports = "async";

View File

@ -1,2 +1,9 @@
'use strict';
require('./common');
require.ensure([], function() {
require('./async');
});
document.body.innerHTML = document.body.innerHTML + "<p>index.js</p>";