-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvite.config.ts
49 lines (48 loc) · 1.36 KB
/
vite.config.ts
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
import { defineConfig } from "vite"
import react from "@vitejs/plugin-react"
import { viteCommonjs } from "@originjs/vite-plugin-commonjs"
/**
* Vite configuration for the application.
*
* @remarks
* This configuration is mostly standard Vite + React setup, with specific accommodations for:
* - WASM decoders used by Cornerstone libraries
* - DICOM parser which currently uses CommonJS format (planned migration to ESM)
*
* @description
* Key configuration points:
* - Uses vite-plugin-commonjs to handle the DICOM parser's CommonJS format
* - Configures worker format as ES modules
* - Excludes Cornerstone CODEC packages from dependency optimization to handle WASM properly
* - Explicitly includes dicom-parser in optimization
* - Ensures WASM files are properly handled as assets
*
* @example
* To use additional WASM decoders, add them to the optimizeDeps.exclude array:
* ```ts
* optimizeDeps: {
* exclude: [
* "@cornerstonejs/codec-new-decoder",
* // ... existing codecs
* ]
* }
* ```
*/
export default defineConfig({
plugins: [
react(),
// for dicom-parser
viteCommonjs(),
],
// seems like only required in dev mode
optimizeDeps: {
exclude: ["@cornerstonejs/dicom-image-loader"],
include: ["dicom-parser"],
},
worker: {
format: "es",
rollupOptions: {
external: ["@icr/polyseg-wasm"],
},
},
})