File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,6 +82,20 @@ function viteHTMLIncludes(options = {}) {
8282 } ) ;
8383 }
8484
85+ function ensureClosedIncludeTags ( html ) {
86+ // This regex finds <include> tags and ensures they are self-closing or properly closed
87+ const regex = / < i n c l u d e ( .* ?) > (? ! ( < \/ i n c l u d e > ) ) / g;
88+ return html . replace ( regex , ( match , attributes ) => {
89+ // Check if it's already self-closing
90+ if ( attributes . trim ( ) . endsWith ( '/' ) ) {
91+ return match ; // No change required
92+ } else {
93+ // Convert to self-closing tag for simplicity
94+ return `<include${ attributes . trimEnd ( ) } />` ;
95+ }
96+ } ) ;
97+ }
98+
8599 function processTemplate ( fragment , locals ) {
86100 processConditionals ( fragment , locals ) ;
87101 processSwitchCases ( fragment , locals ) ;
@@ -96,6 +110,9 @@ function viteHTMLIncludes(options = {}) {
96110 config = resolvedConfig ;
97111 } ,
98112 transformIndexHtml ( html ) {
113+ // Preprocess HTML to ensure <include> tags are closed
114+ html = ensureClosedIncludeTags ( html ) ;
115+
99116 const root = parse ( html ) ;
100117 root . querySelectorAll ( 'include' ) . forEach ( node => {
101118 const src = node . getAttribute ( 'src' ) ;
You can’t perform that action at this time.
0 commit comments