@@ -33,6 +33,39 @@ function reactVirtualized(): PluginOption {
3333 } ,
3434 }
3535}
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+ }
3669
3770// https://vitejs.dev/config/
3871export default defineConfig ( ( { mode } ) => {
@@ -43,20 +76,20 @@ export default defineConfig(({ mode }) => {
4376 port : 3000 ,
4477 } ,
4578 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+ } ,
5892 } ,
59- } ,
6093 } ,
6194 plugins : [
6295 // @TODO : Check if we can remove the config object inside the react plugin
@@ -78,6 +111,7 @@ export default defineConfig(({ mode }) => {
78111 filename : 'service-worker.ts' ,
79112 strategies : 'injectManifest' ,
80113 } ) ,
114+ jsToBottomNoModule ( ) ,
81115 ] ,
82116 // test: {
83117 // globals: true,
@@ -95,10 +129,10 @@ export default defineConfig(({ mode }) => {
95129 port : 3000 ,
96130 proxy : {
97131 '/orchestrator' : {
98- target : 'https://preview .devtron.ai /' ,
132+ target : 'https://devtron-4 .devtron.info /' ,
99133 changeOrigin : true ,
100134 } ,
101- '/grafana' : 'https://preview .devtron.ai /' ,
135+ '/grafana' : 'https://devtron-4 .devtron.info /' ,
102136 } ,
103137 } ,
104138 }
0 commit comments