@@ -51,7 +51,7 @@ const persistPortPlugin = (): Plugin => ({
5151 } ,
5252} )
5353
54- // https://vitejs .dev/config/
54+ // https://vite .dev/config/
5555export default defineConfig ( ( { mode } ) => {
5656 let outDir = "../src/webview-ui/build"
5757
@@ -98,79 +98,39 @@ export default defineConfig(({ mode }) => {
9898 return {
9999 plugins,
100100 resolve : {
101- alias : {
102- "@" : resolve ( __dirname , "./src" ) ,
103- "@src" : resolve ( __dirname , "./src" ) ,
104- "@roo" : resolve ( __dirname , "../src/shared" ) ,
105- } ,
101+ tsconfigPaths : true ,
106102 } ,
107103 build : {
108104 outDir,
109105 emptyOutDir : true ,
110106 reportCompressedSize : false ,
111107 // Generate complete source maps with original TypeScript sources
112108 sourcemap : true ,
113- // Ensure source maps are properly included in the build
114- minify : mode === "production" ? "esbuild" : false ,
109+ // Vite 8 uses Rolldown/Oxc by default; keep non-production modes readable.
110+ minify : mode === "production" ,
115111 // Use a single combined CSS bundle so all webviews share styles
116112 cssCodeSplit : false ,
117- rollupOptions : {
113+ rolldownOptions : {
118114 // Externalize vscode module - it's imported by file-search.ts which is
119115 // dynamically imported by roo-config/index.ts, but should never be bundled
120116 // in the webview since it's not available in the browser context
121117 external : [ "vscode" ] ,
122- input : {
123- index : resolve ( __dirname , "index.html" ) ,
124- } ,
118+ input : resolve ( __dirname , "index.html" ) ,
125119 output : {
126- entryFileNames : `assets/[name].js` ,
127- chunkFileNames : ( chunkInfo ) => {
128- if ( chunkInfo . name === "mermaid-bundle" ) {
129- return `assets/mermaid-bundle.js`
130- }
131- // Default naming for other chunks, ensuring uniqueness from entry
132- return `assets/chunk-[hash].js`
133- } ,
120+ entryFileNames : "assets/[name].js" ,
121+ chunkFileNames : "assets/[name]-[hash].js" ,
134122 assetFileNames : ( assetInfo ) => {
135- const name = assetInfo . name || ""
123+ const name = assetInfo . name ?? ""
136124
137- // Force all CSS into a single predictable file used by both webviews
138125 if ( name . endsWith ( ".css" ) ) {
139126 return "assets/index.css"
140127 }
141128
142- if ( name . endsWith ( ". woff2" ) || name . endsWith ( ".woff" ) || name . endsWith ( ".ttf" ) ) {
129+ if ( / \. ( w o f f 2 ? | t t f ) $ / . test ( name ) ) {
143130 return "assets/fonts/[name][extname]"
144131 }
145- // Ensure source maps are included in the build
146- if ( name . endsWith ( ".map" ) ) {
147- return "assets/[name]"
148- }
149- return "assets/[name][extname]"
150- } ,
151- manualChunks : ( id , { getModuleInfo } ) => {
152- // Consolidate all mermaid code and its direct large dependencies (like dagre)
153- // into a single chunk. The 'channel.js' error often points to dagre.
154- if (
155- id . includes ( "node_modules/mermaid" ) ||
156- id . includes ( "node_modules/dagre" ) || // dagre is a common dep for graph layout
157- id . includes ( "node_modules/cytoscape" ) // another potential graph lib
158- // Add other known large mermaid dependencies if identified
159- ) {
160- return "mermaid-bundle"
161- }
162132
163- // Check if the module is part of any explicitly defined mermaid-related dynamic import
164- // This is a more advanced check if simple path matching isn't enough.
165- const moduleInfo = getModuleInfo ( id )
166- if ( moduleInfo ?. importers . some ( ( importer ) => importer . includes ( "node_modules/mermaid" ) ) ) {
167- return "mermaid-bundle"
168- }
169- if (
170- moduleInfo ?. dynamicImporters . some ( ( importer ) => importer . includes ( "node_modules/mermaid" ) )
171- ) {
172- return "mermaid-bundle"
173- }
133+ return "assets/[name][extname]"
174134 } ,
175135 } ,
176136 } ,
@@ -188,11 +148,6 @@ export default defineConfig(({ mode }) => {
188148 } ,
189149 define,
190150 optimizeDeps : {
191- include : [
192- "mermaid" ,
193- "dagre" , // Explicitly include dagre for pre-bundling
194- // Add other known large mermaid dependencies if identified
195- ] ,
196151 exclude : [ "@vscode/codicons" , "vscode-oniguruma" , "shiki" ] ,
197152 } ,
198153 assetsInclude : [ "**/*.wasm" , "**/*.wav" ] ,
0 commit comments