Compare commits

...
16 Commits
Author SHA1 Message Date
Ross 11d1dc4339 . 2025-06-11 19:32:18 +01:00
Ross 21dca7d4b5 update packages 2025-06-10 10:14:58 +01:00
Ross f596dc83c9 . 2025-06-09 17:01:10 +01:00
Ross a9e3c215ed add props for annontations and viewerstate 2025-06-09 14:02:27 +01:00
Ross 28569a1c94 a lot of fixes 2025-06-09 13:31:56 +01:00
Ross 7d8caebf8c . 2025-06-09 10:18:02 +01:00
Ross adbbf48a28 . 2025-06-09 10:00:08 +01:00
Ross b1db098a49 fix annotation selection 2025-06-03 21:39:07 +01:00
Ross cdbe31df6b add simple annotation navigation 2025-06-03 16:22:01 +01:00
Ross c21fe2cbd7 fix viewport importing 2025-06-03 16:06:37 +01:00
Ross 8c218d42f4 get legacy annotation import working 2025-06-03 15:45:11 +01:00
Ross 2518da4413 numerous more fixes 2025-06-02 12:37:01 +01:00
Ross 43c3f75889 some cleanup and start movinig to multiple instances 2025-06-02 10:39:07 +01:00
Ross 3f6c68523e . 2025-06-02 10:30:21 +01:00
Ross 38620d969b add a new no label arrow tool 2025-06-02 10:17:51 +01:00
Ross b408ba96b3 fix tool import 2025-06-02 09:59:51 +01:00
8 changed files with 4647 additions and 2098 deletions
+64 -2
View File
@@ -7,12 +7,24 @@
<title>Vite + React + TS</title>
</head>
<body>
<div id="root" style="max-height:500px; height:500px; overflow:auto;"></div>
<!-- <div id="root" class="dicom-viewer-test-root" style="max-height:500px; height:500px; overflow:auto;"></div> -->
<div id="root" class="dicom-viewer-root" style="max-height:500px; height:500px; overflow:auto;"
data-images="[&quot;http://localhost:8000/media/atlas/dicom/0fb1283bab62d691bdaf7c7e47b8c674b600cddb.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/c98950f460ed153c14bd1d0d32e712397ace4564.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/512bfc7f9d07d54ae8f92af1ab98be390174d618.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/5f0a6b97da797b7639361732599bfcf607c17dfc.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/c5f854a8c2ac36da60c8a5a2bc215639d5302d20.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/0cec8d98bd80818c38c657b9c5934b30316920a2.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/613166d33e9e35898238f0bd334969c500822bbf.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/48801a3aa1fea5d943cc934b74e9bc7273c1e944.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/db8ddb477387a41b023efae98e7e40be890886ef.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/8720dc9b0b3b2c596f1d87acc951818307b7ad6a.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/24d1e5397fa97dd0c904568a20e4649fea13d1cf.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/bb586d17474988a07b1c90afce456abd7f69a753.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/24fa49c0e482bb885c92b71f74451f558940cb4b.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/6d9b09614f74b21a0b2778a5129d22b3cbafd3da.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/39963ce191beafe943a9cf980f7320adad74c1d5.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/09adc694456f1e51a5ab9c1cf7eaf9d748c938db.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/d4f6521a9e9a26975e1218ba3b7f48a78ac46d8f.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/0e1490ed17cdf2ceb1bcf069400f8f47a4437561.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/2cb43b50760d9335df9a5f2d6bd645daf2a0c917.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/9b02fae29bf6e775c5ba94b0b7158e10d4697ff6.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/9628d1d2fb457bc6f03efa8c980ef3165092230f.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/b879d6488a79d38ba374366f5543aab49fa8cb86.dcm&quot;]"
data-auto-cache-stack="true"
data-viewerstate='{"grid":{"rows":1,"cols":1},"modes":["stack"],"stacks":[{"i":["wadouri:http://localhost:8000/media/atlas/dicom/0fb1283bab62d691bdaf7c7e47b8c674b600cddb.dcm","wadouri:http://localhost:8000/media/atlas/dicom/c98950f460ed153c14bd1d0d32e712397ace4564.dcm","wadouri:http://localhost:8000/media/atlas/dicom/512bfc7f9d07d54ae8f92af1ab98be390174d618.dcm","wadouri:http://localhost:8000/media/atlas/dicom/5f0a6b97da797b7639361732599bfcf607c17dfc.dcm","wadouri:http://localhost:8000/media/atlas/dicom/c5f854a8c2ac36da60c8a5a2bc215639d5302d20.dcm","wadouri:http://localhost:8000/media/atlas/dicom/0cec8d98bd80818c38c657b9c5934b30316920a2.dcm","wadouri:http://localhost:8000/media/atlas/dicom/613166d33e9e35898238f0bd334969c500822bbf.dcm","wadouri:http://localhost:8000/media/atlas/dicom/48801a3aa1fea5d943cc934b74e9bc7273c1e944.dcm","wadouri:http://localhost:8000/media/atlas/dicom/db8ddb477387a41b023efae98e7e40be890886ef.dcm","wadouri:http://localhost:8000/media/atlas/dicom/8720dc9b0b3b2c596f1d87acc951818307b7ad6a.dcm","wadouri:http://localhost:8000/media/atlas/dicom/24d1e5397fa97dd0c904568a20e4649fea13d1cf.dcm","wadouri:http://localhost:8000/media/atlas/dicom/bb586d17474988a07b1c90afce456abd7f69a753.dcm","wadouri:http://localhost:8000/media/atlas/dicom/24fa49c0e482bb885c92b71f74451f558940cb4b.dcm","wadouri:http://localhost:8000/media/atlas/dicom/6d9b09614f74b21a0b2778a5129d22b3cbafd3da.dcm","wadouri:http://localhost:8000/media/atlas/dicom/39963ce191beafe943a9cf980f7320adad74c1d5.dcm","wadouri:http://localhost:8000/media/atlas/dicom/09adc694456f1e51a5ab9c1cf7eaf9d748c938db.dcm","wadouri:http://localhost:8000/media/atlas/dicom/d4f6521a9e9a26975e1218ba3b7f48a78ac46d8f.dcm","wadouri:http://localhost:8000/media/atlas/dicom/0e1490ed17cdf2ceb1bcf069400f8f47a4437561.dcm","wadouri:http://localhost:8000/media/atlas/dicom/2cb43b50760d9335df9a5f2d6bd645daf2a0c917.dcm","wadouri:http://localhost:8000/media/atlas/dicom/9b02fae29bf6e775c5ba94b0b7158e10d4697ff6.dcm","wadouri:http://localhost:8000/media/atlas/dicom/9628d1d2fb457bc6f03efa8c980ef3165092230f.dcm","wadouri:http://localhost:8000/media/atlas/dicom/b879d6488a79d38ba374366f5543aab49fa8cb86.dcm"],"u":"2.1163931708166249655895918785713305273005"}],"stackIdx":[0],"stackPos":[11],"props":[{"voiRange":{"lower":-707.7203723576732,"upper":1313.7029625973},"invert":false,"interpolationType":1,"VOILUTFunction":"LINEAR"}],"cam":[{"viewUp":[0.012033252051397651,-0.42083716478070027,-0.9070563687942972],"viewPlaneNormal":[0.9998766662057034,-0.004091402933210223,0.015162875697125407],"position":[215.72314005628635,-63.00598963917986,24.208010679564232],"focalPoint":[-0.06152398404300907,-62.12301873163119,20.935691053779152],"parallelProjection":true,"parallelScale":117.33333333333333,"viewAngle":90,"flipHorizontal":false,"flipVertical":false,"rotation":148.19404114160696}]}
'
></div>
<!-- <div id="root2" class="dicom-viewer-root" style="max-height:500px; height:500px; overflow:auto;"
data-images="[&quot;http://localhost:8000/media/atlas/dicom/4596ea7654b7a5074d2c3f40039c556b11fb01ae.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/b2fa301bc731d15be3e000402c9a79c114d17aa5.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/66310ef801fbecb37c5ced160c450dfd5ecc6d2d.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/63d2d117bf256a76a61190066f91eda6c4d67c8f.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/181a3575ea7fb8bf8f6449ff61e6e369a3247454.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/7c5c0538339266ac8897fa21c481b2f61172068e.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/1681410681308af7111af6644fed598fde304b96.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/4adcd3d7a64a9c59b530f730ce0d991bf7f27813.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/671e6004c7fb402a627a2282bbf304d7b4dcc12b.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/8d18ac56914b9de72b8aecced09654ec4b2c9bb7.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/74ce708a90dff0636fc4bc914fe47e8b6d9320bd.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/a96b6c9900570e076edf849a0ae3b52734ed2650.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/0183718d9336458478ec42130395d78e01492bd6.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/52eee968bbce5590274346eed43f1837f9daba11.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/961449f88197566c4643fcfd20f48ea4e810490b.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/1a16ad5b25e11739eadbcb8ea461072b100113a0.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/b89ddcc3f499059d2dedb0028a2bb1ce4abf5574.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/c1379c03a4e449c2fa88784d601cb766af907739.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/4fb532d5003c59a73f7e4248f365b1a8660ea710.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/e861b0de042a1f213cbccc995679aacd29c7ef53.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/1a854282afe264c3afff6a6e287cd646b2193a0c.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/f59d6d9bc33160abad3af8e2b246179b3574d884.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/04fadab0ed8b3f1925e601c4f9cfb792c95626c2.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/d45d0b12fb650e65daeeee4e5fa3b21c988597f6.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/e19c47b7787ac45dbc225319dfa143dc2c1fdf1f.dcm&quot;, &quot;http://localhost:8000/media/atlas/dicom/dccabf3103a5be254a45457ce2d8d9ce9cb19a6a.dcm&quot;]"
data-auto-cache-stack="true"
></div> -->
<script type="module" src="/src/main.tsx"></script>
<input type="file" id="dicomInput" multiple />
<button onclick="sendToViewer()">Send to Viewer</button>
<button onclick="testLoadWadouriStack()">Test Load wadouri Stack</button>
<button onclick="testLoadWadouriStack2()">Test Load wadouri Stack 2</button>
<script>
function sendToViewer() {
const files = document.getElementById('dicomInput').files;
@@ -23,7 +35,6 @@ function sendToViewer() {
}
}
function testLoadWadouriStack() {
const urls = [
"https://www.penracourses.org.uk/media/atlas/dicom/IMG_757_XQQyovo.dcm",
@@ -59,6 +70,57 @@ function testLoadWadouriStack() {
alert("Viewer API not ready");
}
}
function testLoadWadouriStack2() {
const urls = [
"https://www.penracourses.org.uk/media/atlas/picture/37b89ead539fdbbc719845333ed89498fc1e2feb",
"https://www.penracourses.org.uk/media/atlas/picture/6eefab8694dbdcb38e8732319f38eabd14068d0d",
"https://www.penracourses.org.uk/media/atlas/picture/27faaddb0167f359bae951020cabd15b9158c15f",
"https://www.penracourses.org.uk/media/atlas/picture/8097cd95acca6c1a97f050ec5c96c1661290058d",
"https://www.penracourses.org.uk/media/atlas/picture/5dd6147fa3362ab52b87903aa670c1ee6e489b78",
"https://www.penracourses.org.uk/media/atlas/picture/c8a794e75a3a28177c71792044518a4a294dc6c6",
"https://www.penracourses.org.uk/media/atlas/picture/6102f3d482e8242cd4ca9e3477c3e8ede5cd6b49",
"https://www.penracourses.org.uk/media/atlas/picture/2f3407a8fafd283a219cec01c45190907b5214f6",
"https://www.penracourses.org.uk/media/atlas/picture/ae61b2c4a09c810a7711aa473b4c5553816a2c47",
"https://www.penracourses.org.uk/media/atlas/picture/c1ac31aebba99645c11e11ac4e96bef8a544ffe1",
"https://www.penracourses.org.uk/media/atlas/picture/c357353b07d4366802b68a9c7ba90104b64f0b06",
"https://www.penracourses.org.uk/media/atlas/picture/ac80a92442a68ca58a0b5c793c9ff39678cf1267",
"https://www.penracourses.org.uk/media/atlas/picture/2856b3a5503540f2d5257d1b1793a3a2ee31024f",
"https://www.penracourses.org.uk/media/atlas/picture/f097bd9d1d9ae33fd20ee57bd4de8187cf338913",
"https://www.penracourses.org.uk/media/atlas/picture/76a764bdc860182374a0701f1c338bdf7d8e05a0",
"https://www.penracourses.org.uk/media/atlas/picture/1c09f607ca2485b2681197e6e8555393879e5a04",
"https://www.penracourses.org.uk/media/atlas/picture/616498815182e1d093c0011b90c3fb309caadb8f",
"https://www.penracourses.org.uk/media/atlas/picture/9d04d2370d3f8e3b0220ff0f460ba12625ef3857",
"https://www.penracourses.org.uk/media/atlas/picture/fb94a8645a0159b0e9725c0718dd723f86008008",
"https://www.penracourses.org.uk/media/atlas/picture/43cb8280cb9dd96ddfde8028cfb20e60dfe5d756",
"https://www.penracourses.org.uk/media/atlas/picture/65a8cbbc9b837e66e1f07ed6ecbc1dd22ea28b65",
"https://www.penracourses.org.uk/media/atlas/picture/147a29e905fcc3c0bd2d38848beb80328c007436",
"https://www.penracourses.org.uk/media/atlas/picture/2b8fde7b6736bd5eba3f64bd26b291634ff9a719",
"https://www.penracourses.org.uk/media/atlas/picture/9904072307db5935bc07c1eda762aebb972950e8",
"https://www.penracourses.org.uk/media/atlas/picture/3b4b4f1ab6c5b944c267209bb298281e0f669a2d",
"https://www.penracourses.org.uk/media/atlas/picture/6530f91afa0021dd5ca6f4f067112ef647c42314",
"https://www.penracourses.org.uk/media/atlas/picture/2a071c131e484213b7198c6320e8a63a176b34b0",
"https://www.penracourses.org.uk/media/atlas/picture/efb13b2d01651b542880ef8d1d09487bc128a459",
"https://www.penracourses.org.uk/media/atlas/picture/272800e852655f6c9ec107bd31c620e8f774afea",
"https://www.penracourses.org.uk/media/atlas/picture/3434977ed6d75f858b02e86c9e616cd774c5c9bf",
"https://www.penracourses.org.uk/media/atlas/picture/1b1fa4cfd2a177db0f449e4a37634250e69ec7e1",
"https://www.penracourses.org.uk/media/atlas/picture/72ea7d1b931f246e340665cbe067c3cb4a22176d",
"https://www.penracourses.org.uk/media/atlas/picture/f8c1d6dd25617f0c710e2f01b05d1cba3d72367f",
"https://www.penracourses.org.uk/media/atlas/picture/333b535df6f5e501a5a8a70c2156fcb3f94c23f8",
"https://www.penracourses.org.uk/media/atlas/picture/2ccb2a892d1d2d7022ddf7e59ccb3a184fb2676a",
"https://www.penracourses.org.uk/media/atlas/picture/a9bef320ed90508f5466010a6af8eee86b6324c2",
"https://www.penracourses.org.uk/media/atlas/picture/ba714cdffe76cfa95f8f7d9dee940d1ed8b8be77",
"https://www.penracourses.org.uk/media/atlas/picture/1f2a1b7a371f72a2696c003f551caa92ebee2cc7",
"https://www.penracourses.org.uk/media/atlas/picture/387d0fb40b96d5c532d66329f964811ca54d9c46",
"https://www.penracourses.org.uk/media/atlas/picture/71e0c4b40bd12bb7fa5d8aa30e60c58dd936ccc0"
];
const wadouriList = urls.map(url => "wadouri:" + url);
if (window.loadDicomStackFromWadouriList) {
window.loadDicomStackFromWadouriList(wadouriList);
} else {
alert("Viewer API not ready");
}
}
</script>
</body>
+3259 -1584
View File
File diff suppressed because it is too large Load Diff
+10 -8
View File
@@ -5,16 +5,19 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build": "tsc && vite build && cp dist/index.js /home/ross/rad/rad/rad/static/dv3d/index.js",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@cornerstonejs/calculate-suv": "1.1.0",
"@cornerstonejs/core": "^2.1.16",
"@cornerstonejs/dicom-image-loader": "^2.1.16",
"@cornerstonejs/nifti-volume-loader": "^2.1.16",
"@cornerstonejs/tools": "^2.1.16",
"@cornerstonejs/calculate-suv": "^1.1.0",
"@cornerstonejs/core": "^3.19.5",
"@cornerstonejs/dicom-image-loader": "^3.19.5",
"@cornerstonejs/nifti-volume-loader": "^3.19.5",
"@cornerstonejs/tools": "^3.19.5",
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
"@cornerstonejs/codec-charls": "^1.2.3",
"@cornerstonejs/codec-openjpeg": "^1.2.4",
"dcmjs": "0.33.0",
"dicom-parser": "1.8.21",
"dicomweb-client": "0.10.4",
@@ -43,9 +46,8 @@
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-terser": "^7.0.2",
"typescript": "^5.6.3",
"vite": "^5.2.0",
"vite-plugin-static-copy": "^1.0.5"
}
}
}
+1191 -493
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,5 @@
import { ArrowAnnotateTool } from "@cornerstonejs/tools";
export class NoLabelArrowAnnotateTool extends ArrowAnnotateTool {
static toolName = "NoLabelArrowAnnotate";
}
+31 -1
View File
@@ -19,4 +19,34 @@ html, body, #root {
opacity: 1 !important;
pointer-events: auto;
}
*/
*/
.dicom-viewer-root, #root {
width: 100vw;
height: 100vh;
min-height: 0;
min-width: 0;
position: relative;
}
.dicom-viewer-test-root {
box-sizing: border-box;
color: rgb(128, 128, 128);
display: block;
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-size: 16px;
font-weight: 400;
height: 500px;
line-height: 24px;
max-height: 500px;
overflow-x: auto;
overflow-y: auto;
text-align: start;
text-size-adjust: 100%;
unicode-bidi: isolate;
width: 1296px;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
/* In your global CSS */
.cornerstone-viewport, .cornerstone-canvas {
cursor: inherit !important;
}
+73 -6
View File
@@ -1,12 +1,79 @@
import React from 'react'
import { createRoot } from "react-dom/client";
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import Nifti from './Nifti.tsx'
import './index.css'
import { createImageIds, availableImageIds } from "./lib/createImageIds.ts"
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
{/* <Nifti /> */}
</React.StrictMode>,
)
// Helper to convert URLs to wadouri
const toWadouri = (arr: string[]) =>
arr.map(url => url.startsWith("wadouri:") ? url : `wadouri:${url}`);
export function mountDicomViewers() {
// Test containers
const test_containers = document.querySelectorAll(".dicom-viewer-test-root");
test_containers.forEach((container) => {
const id = container.id || '';
const imageStacks = () => availableImageIds();
createRoot(container).render(
<App
container_id={id}
imageStacks={imageStacks}
/>
);
});
// Main containers
const containers = document.querySelectorAll(".dicom-viewer-root");
containers.forEach((container) => {
const id = container.id || '';
let imageStacks;
const dataImages = container.getAttribute('data-images');
if (dataImages) {
let parsed;
try {
parsed = JSON.parse(dataImages);
} catch (e) {
console.error("Invalid data-images JSON:", e);
parsed = [];
}
if (Array.isArray(parsed) && parsed.length > 0 && typeof parsed[0] === "string") {
imageStacks = () => Promise.resolve([toWadouri(parsed)]);
} else if (Array.isArray(parsed)) {
imageStacks = () => Promise.resolve(parsed.map(
stack => Array.isArray(stack) ? toWadouri(stack) : []
));
} else {
imageStacks = () => Promise.resolve([[]]);
}
} else {
imageStacks = () => Promise.resolve([[]]);
}
const autoCacheStackAttr = container.getAttribute('data-auto-cache-stack');
const autoCacheStack = autoCacheStackAttr === "true" || autoCacheStackAttr === "1";
const annotationJson = container.getAttribute('data-annotationjson');
const viewerState = container.getAttribute('data-viewerstate');
console.log("Mounting DICOM viewer:")
console.log(viewerState, annotationJson, autoCacheStack);
createRoot(container).render(
<App
container_id={id}
imageStacks={imageStacks}
autoCacheStack={autoCacheStack}
annotationJson={annotationJson ? annotationJson : undefined}
viewerState={viewerState ? viewerState : undefined}
/>
);
});
}
// Optionally, call it immediately for static containers:
mountDicomViewers();
// Optionally, expose globally for dynamic use:
(window as any).mountDicomViewers = mountDicomViewers;
+14 -4
View File
@@ -29,13 +29,11 @@ import { viteCommonjs } from "@originjs/vite-plugin-commonjs"
* }
* ```
*/
export default defineConfig({
export default defineConfig(({ command }) => ({
plugins: [
react(),
// for dicom-parser
viteCommonjs(),
],
// seems like only required in dev mode
optimizeDeps: {
exclude: ["@cornerstonejs/dicom-image-loader"],
include: ["dicom-parser"],
@@ -46,4 +44,16 @@ export default defineConfig({
external: ["@icr/polyseg-wasm"],
},
},
})
base: command === "build" ? "/static/dv3d/" : "/",
build: {
rollupOptions: {
output: {
entryFileNames: `index.js`,
chunkFileNames: `[name].js`,
assetFileNames: `[name][extname]`,
},
},
outDir: "dist",
emptyOutDir: true,
},
}))