Update webview-ui Vite config (#9493)

This commit is contained in:
Hannes Rudolph 2025-11-21 18:46:35 -07:00 committed by GitHub
parent af021623cd
commit 204c71c62f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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]"