diff --git a/webview-ui/vite.config.ts b/webview-ui/vite.config.ts index b38452a9902..d2cc797aa4f 100644 --- a/webview-ui/vite.config.ts +++ b/webview-ui/vite.config.ts @@ -27,9 +27,9 @@ const wasmPlugin = (): Plugin => ({ const wasmBinary = await import(id) return ` - const wasmModule = new WebAssembly.Module(${wasmBinary.default}); - export default wasmModule; - ` + const wasmModule = new WebAssembly.Module(${wasmBinary.default}); + export default wasmModule; + ` } }, }) @@ -100,7 +100,13 @@ export default defineConfig(({ mode }) => { sourcemap: true, // Ensure source maps are properly included in the build minify: mode === "production" ? "esbuild" : false, + // Use a single combined CSS bundle so both webviews share styles + cssCodeSplit: false, rollupOptions: { + input: { + index: resolve(__dirname, "index.html"), + "browser-panel": resolve(__dirname, "browser-panel.html"), + }, output: { entryFileNames: `assets/[name].js`, chunkFileNames: (chunkInfo) => { @@ -111,16 +117,18 @@ export default defineConfig(({ mode }) => { return `assets/chunk-[hash].js` }, assetFileNames: (assetInfo) => { - if ( - assetInfo.name && - (assetInfo.name.endsWith(".woff2") || - assetInfo.name.endsWith(".woff") || - assetInfo.name.endsWith(".ttf")) - ) { + const name = assetInfo.name || "" + + // Force all CSS into a single predictable file used by both webviews + if (name.endsWith(".css")) { + return "assets/index.css" + } + + if (name.endsWith(".woff2") || name.endsWith(".woff") || name.endsWith(".ttf")) { return "assets/fonts/[name][extname]" } // Ensure source maps are included in the build - if (assetInfo.name && assetInfo.name.endsWith(".map")) { + if (name.endsWith(".map")) { return "assets/[name]" } return "assets/[name][extname]"