25 lines
918 B
TypeScript
25 lines
918 B
TypeScript
import { defineConfig } from 'vite';
|
|
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
|
|
// Vite 配置 / Vite configuration
|
|
// 关键: COOP/COEP header 让 typst.ts 的线程化 WASM 可用 / COOP/COEP enable threaded typst.ts WASM.
|
|
export default defineConfig({
|
|
plugins: [svelte()],
|
|
server: {
|
|
port: 5173,
|
|
strictPort: true, // 与 Tauri 约定一致 / Match Tauri convention
|
|
headers: {
|
|
// 跨源隔离 (线程化 WASM 必须) / Cross-origin isolation (required by threaded WASM)
|
|
'Cross-Origin-Opener-Policy': 'same-origin',
|
|
'Cross-Origin-Embedder-Policy': 'require-corp',
|
|
},
|
|
},
|
|
// 排除 typst.ts 的 WASM 包,避免 Vite 预打包 / Exclude typst.ts WASM from dep pre-bundling
|
|
optimizeDeps: {
|
|
exclude: ['@myriaddreamin/typst-ts-web-compiler', '@myriaddreamin/typst-ts-renderer'],
|
|
},
|
|
worker: {
|
|
format: 'es', // ES module worker / ES module workers
|
|
},
|
|
});
|