mirror of
https://github.com/vector-im/element-call.git
synced 2026-01-18 02:32:27 +00:00
Default vite config to support using local build of crypto wasm (#3038)
* Devex: Default vite config to support using local build of crypto wasm * use realpathSync and make it work with linked and not-linked We need to use sync because an async defineConfig fails for the embedded exports. * also allow just linking matrix-sdk-crypto-wasm (without js-sdk linking) --------- Co-authored-by: Timo <toger5@hotmail.de> Co-authored-by: Timo <16718859+toger5@users.noreply.github.com> Co-authored-by: Robin <robin@robin.town>
This commit is contained in:
@@ -337,7 +337,7 @@ export function getRelativeRoomUrl(
|
||||
}
|
||||
|
||||
/**
|
||||
* Perfom a network operation with retries on ConnectionError.
|
||||
* Perform a network operation with retries on ConnectionError.
|
||||
* If the error is not retryable, or the max number of retries is reached, the error is rethrown.
|
||||
* Supports handling of matrix quotas.
|
||||
*/
|
||||
|
||||
@@ -5,13 +5,14 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { defineConfig, loadEnv } from "vite";
|
||||
import { defineConfig, loadEnv, searchForWorkspaceRoot } from "vite";
|
||||
import svgrPlugin from "vite-plugin-svgr";
|
||||
import { createHtmlPlugin } from "vite-plugin-html";
|
||||
import { codecovVitePlugin } from "@codecov/vite-plugin";
|
||||
import { sentryVitePlugin } from "@sentry/vite-plugin";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import basicSsl from "@vitejs/plugin-basic-ssl";
|
||||
import { realpathSync } from "fs";
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(({ mode, packageType }) => {
|
||||
@@ -64,9 +65,25 @@ export default defineConfig(({ mode, packageType }) => {
|
||||
);
|
||||
}
|
||||
|
||||
// The crypto WASM module is imported dynamically. Since it's common
|
||||
// for developers to use a linked copy of matrix-js-sdk or Rust
|
||||
// crypto (which could reside anywhere on their file system), Vite
|
||||
// needs to be told to recognize it as a legitimate file access.
|
||||
const allow = [searchForWorkspaceRoot(process.cwd())];
|
||||
for (const path of [
|
||||
"node_modules/matrix-js-sdk/node_modules/@matrix-org/matrix-sdk-crypto-wasm",
|
||||
"node_modules/@matrix-org/matrix-sdk-crypto-wasm",
|
||||
]) {
|
||||
try {
|
||||
allow.push(realpathSync(path));
|
||||
} catch {}
|
||||
}
|
||||
console.log("Allowed vite paths:", allow);
|
||||
|
||||
return {
|
||||
server: {
|
||||
port: 3000,
|
||||
fs: { allow },
|
||||
},
|
||||
build: {
|
||||
sourcemap: true,
|
||||
|
||||
Reference in New Issue
Block a user