Skip to content

Commit 204c71c

Browse files
Update webview-ui Vite config (#9493)
1 parent af02162 commit 204c71c

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

webview-ui/vite.config.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ const wasmPlugin = (): Plugin => ({
2727
const wasmBinary = await import(id)
2828

2929
return `
30-
const wasmModule = new WebAssembly.Module(${wasmBinary.default});
31-
export default wasmModule;
32-
`
30+
const wasmModule = new WebAssembly.Module(${wasmBinary.default});
31+
export default wasmModule;
32+
`
3333
}
3434
},
3535
})
@@ -100,7 +100,13 @@ export default defineConfig(({ mode }) => {
100100
sourcemap: true,
101101
// Ensure source maps are properly included in the build
102102
minify: mode === "production" ? "esbuild" : false,
103+
// Use a single combined CSS bundle so both webviews share styles
104+
cssCodeSplit: false,
103105
rollupOptions: {
106+
input: {
107+
index: resolve(__dirname, "index.html"),
108+
"browser-panel": resolve(__dirname, "browser-panel.html"),
109+
},
104110
output: {
105111
entryFileNames: `assets/[name].js`,
106112
chunkFileNames: (chunkInfo) => {
@@ -111,16 +117,18 @@ export default defineConfig(({ mode }) => {
111117
return `assets/chunk-[hash].js`
112118
},
113119
assetFileNames: (assetInfo) => {
114-
if (
115-
assetInfo.name &&
116-
(assetInfo.name.endsWith(".woff2") ||
117-
assetInfo.name.endsWith(".woff") ||
118-
assetInfo.name.endsWith(".ttf"))
119-
) {
120+
const name = assetInfo.name || ""
121+
122+
// Force all CSS into a single predictable file used by both webviews
123+
if (name.endsWith(".css")) {
124+
return "assets/index.css"
125+
}
126+
127+
if (name.endsWith(".woff2") || name.endsWith(".woff") || name.endsWith(".ttf")) {
120128
return "assets/fonts/[name][extname]"
121129
}
122130
// Ensure source maps are included in the build
123-
if (assetInfo.name && assetInfo.name.endsWith(".map")) {
131+
if (name.endsWith(".map")) {
124132
return "assets/[name]"
125133
}
126134
return "assets/[name][extname]"

0 commit comments

Comments
 (0)