Fix Electron production CSS not loading under file://.
Strip crossorigin from the built index so stylesheets apply in the packaged app, and use a relative manifest path for the same reason.
This commit is contained in:
@@ -136,6 +136,21 @@ function servePublicAssets() {
|
||||
}
|
||||
|
||||
// CORS proxy for Matrix homeservers during development
|
||||
/**
|
||||
* Vite adds crossorigin to module/CSS tags when base is relative (./).
|
||||
* Electron serves the build via file:// — those assets then fail CORS checks
|
||||
* and the app renders with browser defaults (black text, broken spacing).
|
||||
*/
|
||||
function stripCrossoriginForFileProtocol() {
|
||||
return {
|
||||
name: 'strip-crossorigin-for-file-protocol',
|
||||
apply: 'build',
|
||||
transformIndexHtml(html) {
|
||||
return html.replace(/\s+crossorigin/g, '');
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function corsProxyMiddleware() {
|
||||
return {
|
||||
name: 'vite-plugin-cors-proxy',
|
||||
@@ -228,6 +243,7 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
stripCrossoriginForFileProtocol(),
|
||||
corsProxyMiddleware(), // Add CORS proxy for development
|
||||
serverMatrixSdkCryptoWasm('/node_modules/.vite/deps/pkg/matrix_sdk_crypto_wasm_bg.wasm'),
|
||||
serveGifWorker(),
|
||||
|
||||
Reference in New Issue
Block a user