@@ -33,6 +33,39 @@ function reactVirtualized(): PluginOption {
33
33
} ,
34
34
}
35
35
}
36
+ // this method is used to move all the script and styles to bottom after body
37
+ const jsToBottomNoModule = ( ) => {
38
+ return {
39
+ name : 'no-attribute' ,
40
+ transformIndexHtml ( html ) {
41
+ let customInjection = ''
42
+ const scriptTag = html . match ( / < s c r i p t t y p e = " m o d u l e " [ ^ > ] * > ( .* ?) < \/ s c r i p t [ ^ > ] * > / ) [ 0 ]
43
+ console . log ( '\n SCRIPT TAG' , scriptTag , '\n' )
44
+ html = html . replace ( scriptTag , '' )
45
+ customInjection += scriptTag
46
+
47
+ const linkTagModulePreloadList = [ ...html . matchAll ( / < l i n k r e l = " m o d u l e p r e l o a d " [ ^ > ] * > / g) ]
48
+ console . log ( '------------------------------------------------------------' )
49
+ linkTagModulePreloadList . forEach ( ( linkData ) => {
50
+ console . log ( '\n modulepreload' , linkData [ 0 ] , '\n' )
51
+ html = html . replace ( linkData [ 0 ] , '' )
52
+ customInjection += linkData [ 0 ]
53
+ } )
54
+
55
+ let linkTagStyleSheetList = [ ...html . matchAll ( / < l i n k r e l = " s t y l e s h e e t " [ ^ > ] * > / g) ]
56
+ console . log ( '------------------------------------------------------------' )
57
+ linkTagStyleSheetList . forEach ( ( linkData ) => {
58
+ console . log ( '\n stylesheet' , linkData [ 0 ] , '\n' )
59
+ html = html . replace ( linkData [ 0 ] , '' )
60
+ customInjection += linkData [ 0 ]
61
+ } )
62
+
63
+ html = html . replace ( '<!-- # INSERT SCRIPT HERE -->' , customInjection )
64
+ console . log ( '------------------------------------------------------------' )
65
+ return html
66
+ } ,
67
+ }
68
+ }
36
69
37
70
// https://vitejs.dev/config/
38
71
export default defineConfig ( ( { mode } ) => {
@@ -43,20 +76,20 @@ export default defineConfig(({ mode }) => {
43
76
port : 3000 ,
44
77
} ,
45
78
build : {
46
- sourcemap : true ,
47
- rollupOptions : {
48
- output : {
49
- manualChunks ( id : string ) {
50
- // separating the common lib chunk
51
- if ( id . includes ( 'devtron-fe-common-lib' ) ) {
52
- return '@devtron-common' ;
53
- }
54
- if ( id . includes ( '@devtron' ) ) {
55
- return '@devtron' ;
56
- }
57
- } ,
79
+ sourcemap : true ,
80
+ rollupOptions : {
81
+ output : {
82
+ manualChunks ( id : string ) {
83
+ // separating the common lib chunk
84
+ if ( id . includes ( 'devtron-fe-common-lib' ) ) {
85
+ return '@devtron-common'
86
+ }
87
+ if ( id . includes ( '@devtron' ) ) {
88
+ return '@devtron'
89
+ }
90
+ } ,
91
+ } ,
58
92
} ,
59
- } ,
60
93
} ,
61
94
plugins : [
62
95
// @TODO : Check if we can remove the config object inside the react plugin
@@ -78,6 +111,7 @@ export default defineConfig(({ mode }) => {
78
111
filename : 'service-worker.ts' ,
79
112
strategies : 'injectManifest' ,
80
113
} ) ,
114
+ jsToBottomNoModule ( ) ,
81
115
] ,
82
116
// test: {
83
117
// globals: true,
@@ -95,10 +129,10 @@ export default defineConfig(({ mode }) => {
95
129
port : 3000 ,
96
130
proxy : {
97
131
'/orchestrator' : {
98
- target : 'https://preview .devtron.ai /' ,
132
+ target : 'https://devtron-4 .devtron.info /' ,
99
133
changeOrigin : true ,
100
134
} ,
101
- '/grafana' : 'https://preview .devtron.ai /' ,
135
+ '/grafana' : 'https://devtron-4 .devtron.info /' ,
102
136
} ,
103
137
} ,
104
138
}
0 commit comments