diff --git a/README.md b/README.md index 7525085..7112caa 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,10 @@ const config = { title: 'Webpack demo', // Optional, defaults to `{ lang: 'en' }` htmlAttributes: { lang: 'en' }, + // Optional, any additional HTML attached within + head: '', + // Optional, any additional HTML attached within + body: '', // Optional cssAttributes: { rel: 'preload' }, // Optional diff --git a/__snapshots__/test.js.snap b/__snapshots__/test.js.snap index 354e955..c73939c 100644 --- a/__snapshots__/test.js.snap +++ b/__snapshots__/test.js.snap @@ -1,5 +1,33 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`additional body 1`] = ` +" + + + + + + + +
Demo
+ + " +`; + +exports[`additional head 1`] = ` +" + + + + + + + + + + " +`; + exports[`custom chunks 1`] = ` " diff --git a/index.js b/index.js index 08be102..53f1575 100644 --- a/index.js +++ b/index.js @@ -81,6 +81,8 @@ function defaultTemplate({ htmlAttributes = { lang: 'en', }, + head = '', + body = '', cssAttributes = {}, jsAttributes = {}, }) { @@ -103,10 +105,10 @@ function defaultTemplate({ ${title} - ${cssTags} + ${head}${cssTags} - ${jsTags} + ${body}${jsTags} `; } diff --git a/test.js b/test.js index 1ec228a..754562e 100644 --- a/test.js +++ b/test.js @@ -63,6 +63,28 @@ test('custom lang', () => { }); }); +test('additional head', () => { + return compiler( + {}, + getConfig({ + context: { + head: + '', + }, + }) + ).then(result => { + expect(result.compilation.assets['index.html']._value).toMatchSnapshot(); + }); +}); + +test('additional body', () => { + return compiler({}, getConfig({ context: { body: '
Demo
' } })).then( + result => { + expect(result.compilation.assets['index.html']._value).toMatchSnapshot(); + } + ); +}); + test('custom js attribute', () => { return compiler( {},