1
- import { defineConfig , PluginOption , loadEnv } from 'vite'
1
+ import { defineConfig , PluginOption , loadEnv , splitVendorChunkPlugin } from 'vite'
2
2
import react from '@vitejs/plugin-react'
3
3
import svgr from 'vite-plugin-svgr'
4
4
import fs from 'node:fs/promises'
@@ -8,7 +8,6 @@ import { createRequire } from 'node:module'
8
8
import requireTransform from 'vite-plugin-require-transform'
9
9
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
10
10
import { VitePWA } from 'vite-plugin-pwa'
11
- import replace from '@rollup/plugin-replace'
12
11
13
12
const WRONG_CODE = `import { bpfrpt_proptype_WindowScroller } from "../WindowScroller.js";`
14
13
@@ -44,14 +43,36 @@ export default defineConfig(({ mode }) => {
44
43
port : 3000 ,
45
44
} ,
46
45
build : {
47
- sourcemap : true ,
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-fe-common-lib' ;
53
+ }
54
+ if ( id . includes ( '@devtron' ) ) {
55
+ return '@devtron' ;
56
+ }
57
+ // creating a chunk to react routes deps. Reducing the vendor chunk size
58
+ if (
59
+ id . includes ( 'react-router-dom' ) ||
60
+ id . includes ( '@react' ) ||
61
+ id . includes ( 'react-router' )
62
+ ) {
63
+ return '@react-router' ;
64
+ }
65
+ } ,
66
+ } ,
67
+ } ,
48
68
} ,
49
69
plugins : [
50
70
// @TODO : Check if we can remove the config object inside the react plugin
51
71
react ( {
52
72
// Use React plugin in all *.jsx and *.tsx files
53
73
include : '**/*.{jsx,tsx}' ,
54
74
} ) ,
75
+ splitVendorChunkPlugin ( ) ,
55
76
svgr ( {
56
77
svgrOptions : { } ,
57
78
} ) ,
0 commit comments