Change headReg and bodyReg to allow spaces (#709)
* change headReg and bodyReg to allow spaces * change regex to only allow space before closing tag
This commit is contained in:
parent
2cc10df68f
commit
bd043db35d
4
index.js
4
index.js
|
|
@ -521,8 +521,8 @@ HtmlWebpackPlugin.prototype.generateAssetTags = function (assets) {
|
|||
*/
|
||||
HtmlWebpackPlugin.prototype.injectAssetsIntoHtml = function (html, assets, assetTags) {
|
||||
var htmlRegExp = /(<html[^>]*>)/i;
|
||||
var headRegExp = /(<\/head>)/i;
|
||||
var bodyRegExp = /(<\/body>)/i;
|
||||
var headRegExp = /(<\/head\s*>)/i;
|
||||
var bodyRegExp = /(<\/body\s*>)/i;
|
||||
var body = assetTags.body.map(this.createHtmlTag);
|
||||
var head = assetTags.head.map(this.createHtmlTag);
|
||||
|
||||
|
|
|
|||
|
|
@ -1513,4 +1513,32 @@ describe('HtmlWebpackPlugin', function () {
|
|||
},
|
||||
[/^<script type="text\/javascript" src="app_bundle\.js"><\/script>$/], null, done);
|
||||
});
|
||||
|
||||
it('allows you to inject the assets into the body of the given spaced closing tag template', function (done) {
|
||||
testHtmlPlugin({
|
||||
entry: path.join(__dirname, 'fixtures/index.js'),
|
||||
output: {
|
||||
path: OUTPUT_DIR,
|
||||
filename: 'index_bundle.js'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin({
|
||||
inject: 'body',
|
||||
template: path.join(__dirname, 'fixtures/spaced_plain.html')
|
||||
})]
|
||||
}, [/<body>[\s]*<script type="text\/javascript" src="index_bundle.js"><\/script>[\s]*<\/body\s>/], null, done);
|
||||
});
|
||||
|
||||
it('allows you to inject the assets into the head of the given spaced closing tag template', function (done) {
|
||||
testHtmlPlugin({
|
||||
entry: path.join(__dirname, 'fixtures/index.js'),
|
||||
output: {
|
||||
path: OUTPUT_DIR,
|
||||
filename: 'index_bundle.js'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin({
|
||||
inject: 'head',
|
||||
template: path.join(__dirname, 'fixtures/spaced_plain.html')
|
||||
})]
|
||||
}, [/<head>[\s]*<script type="text\/javascript" src="index_bundle.js"><\/script>[\s]*<\/head\s>/], null, done);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
<!doctype html>
|
||||
<html lang="en" manifest="foo.appcache">
|
||||
<head>
|
||||
</head >
|
||||
<body>
|
||||
</body >
|
||||
</html>
|
||||
Loading…
Reference in New Issue