File tree Expand file tree Collapse file tree 4 files changed +58
-2
lines changed Expand file tree Collapse file tree 4 files changed +58
-2
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ const config = {
2626 title: ' Webpack demo' ,
2727 // Optional, defaults to `{ lang: 'en' }`
2828 htmlAttributes: { lang: ' en' },
29+ // Optional, any additional HTML attached within <head>
30+ head: ' ' ,
31+ // Optional, any additional HTML attached within <body>
32+ body: ' ' ,
2933 // Optional
3034 cssAttributes: { rel: ' preload' },
3135 // Optional
Original file line number Diff line number Diff line change 11// Jest Snapshot v1, https://goo.gl/fbAQLP
22
3+ exports [` additional body 1` ] = `
4+ "<!DOCTYPE html>
5+ <html lang =\\"en\\">
6+ <head>
7+ <meta charset =\\"UTF-8\\">
8+ <title></title>
9+
10+ </head>
11+ <body>
12+ <div>Demo</div><script src =\\"runtime~main.js\\"></script><script src =\\"main.js\\"></script>
13+ </body>
14+ </html>"
15+ `;
16+
17+ exports[`additional head 1`] = `
18+ " <!DOCTYPE html>
19+ <html lang=\\" en\\">
20+ <head>
21+ <meta charset =\\"UTF-8\\">
22+ <title></title>
23+ <meta name =\\"viewport\\" content =\\"width=device-width, initial-scale =1.0\\" />
24+ </head>
25+ <body >
26+ <script src =\\"runtime~main.js\\"></script><script src =\\"main.js\\"></script>
27+ </body>
28+ </html>"
29+ `;
30+
331exports[`custom chunks 1`] = `
432" <!DOCTYPE html>
533 <html lang=\\" en\\">
Original file line number Diff line number Diff line change @@ -81,6 +81,8 @@ function defaultTemplate({
8181 htmlAttributes = {
8282 lang : 'en' ,
8383 } ,
84+ head = '' ,
85+ body = '' ,
8486 cssAttributes = { } ,
8587 jsAttributes = { } ,
8688} ) {
@@ -103,10 +105,10 @@ function defaultTemplate({
103105 <head>
104106 <meta charset="UTF-8">
105107 <title>${ title } </title>
106- ${ cssTags }
108+ ${ head } ${ cssTags }
107109 </head>
108110 <body>
109- ${ jsTags }
111+ ${ body } ${ jsTags }
110112 </body>
111113 </html>` ;
112114}
Original file line number Diff line number Diff line change @@ -63,6 +63,28 @@ test('custom lang', () => {
6363 } ) ;
6464} ) ;
6565
66+ test ( 'additional head' , ( ) => {
67+ return compiler (
68+ { } ,
69+ getConfig ( {
70+ context : {
71+ head :
72+ '<meta name="viewport" content="width=device-width, initial-scale=1.0" />' ,
73+ } ,
74+ } )
75+ ) . then ( result => {
76+ expect ( result . compilation . assets [ 'index.html' ] . _value ) . toMatchSnapshot ( ) ;
77+ } ) ;
78+ } ) ;
79+
80+ test ( 'additional body' , ( ) => {
81+ return compiler ( { } , getConfig ( { context : { body : '<div>Demo</div>' } } ) ) . then (
82+ result => {
83+ expect ( result . compilation . assets [ 'index.html' ] . _value ) . toMatchSnapshot ( ) ;
84+ }
85+ ) ;
86+ } ) ;
87+
6688test ( 'custom js attribute' , ( ) => {
6789 return compiler (
6890 { } ,
You can’t perform that action at this time.
0 commit comments