Commit cb83d12 1 parent 74b0d31 commit cb83d12 Copy full SHA for cb83d12
File tree 1 file changed +13
-10
lines changed
1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -26,16 +26,19 @@ export default defineConfig(({ mode }) => {
26
26
const autoInject = ( ) => {
27
27
return {
28
28
name : 'html-transform' ,
29
- transformIndexHtml ( html ) {
30
- const pattern = / < ! - - .* V I T E _ A U T O I N J E C T .* - - > / ;
31
- // check if the pattern exists in the html, if not, throw error
32
- if ( ! pattern . test ( html ) ) {
33
- throw new Error ( `Could not find pattern ${ pattern } in the html file` ) ;
34
- }
35
- return html . replace (
36
- pattern ,
37
- '<!-- Vite injected: --><script type="module" src="/src/main.js"></script>'
38
- ) ;
29
+ transformIndexHtml : {
30
+ order : 'pre' ,
31
+ handler ( html ) {
32
+ const pattern = / < ! - - .* V I T E _ A U T O I N J E C T .* - - > / ;
33
+ // check if the pattern exists in the html, if not, throw error
34
+ if ( ! pattern . test ( html ) ) {
35
+ throw new Error ( `Could not find pattern ${ pattern } in the html file` ) ;
36
+ }
37
+ return html . replace (
38
+ pattern ,
39
+ '<!-- Vite injected! --><script type="module" src="/src/main.js"></script>'
40
+ ) ;
41
+ } ,
39
42
} ,
40
43
} ;
41
44
} ;
You can’t perform that action at this time.
0 commit comments