-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
53 lines (51 loc) · 1.97 KB
/
Copy pathvite.config.ts
File metadata and controls
53 lines (51 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { sveltekit } from "@sveltejs/kit/vite";
import basicSsl from "@vitejs/plugin-basic-ssl";
import legacy from '@vitejs/plugin-legacy'
import { defineConfig } from "vite";
import { readFileSync } from "node:fs";
const pkg = JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf-8"),
);
export default defineConfig(({ mode }) => ({
// `npm run dev:https` (--mode https) serves over TLS with a generated
// self-signed cert. Needed for phone/LAN testing of secure-context APIs
// (geolocation for live location, clipboard, …) — plain-http origins
// other than localhost block them. Accept the browser's cert warning
// once on the device.
plugins: [
...(mode === "https" ? [basicSsl()] : []),
sveltekit(),
{
...legacy({
targets: [
'ios >= 15.8',
'> 0.5%',
'not dead'
],
renderLegacyChunks: true
}),
apply(config, { isSsrBuild }) {
return !isSsrBuild;
}
}
],
define: {
// App version (from package.json) exposed to the client bundle.
__APP_VERSION__: JSON.stringify(pkg.version),
},
optimizeDeps: {
// E2EE rust-crypto WASM. The package loads its .wasm via
// `new URL("./pkg/…_bg.wasm", import.meta.url)`; when Vite pre-bundles
// the dep with esbuild, that reference resolves into `.vite/deps/pkg/…`
// which is never emitted there → the fetch 404s and `initRustCrypto`
// throws "WebAssembly.compile … HTTP status code is not ok". Excluding
// it routes the package through Vite's normal asset pipeline, which
// rewrites the URL to the correctly served hashed asset. (Same fix
// Element Web / matrix-react-sdk use.)
exclude: ["@matrix-org/matrix-sdk-crypto-wasm"],
},
server: {
host: "0.0.0.0",
port: 5173,
},
}));