cornerstonejs / cornerstone-nifti-image-loader

[Deprecated] Use Cornerstone3D Instead https://cornerstonejs.org/
MIT License
56 stars 27 forks source link

How to use it with vite #63

Open bjhuang103 opened 1 year ago

bjhuang103 commented 1 year ago

I try to use it with vue + vite, But it have some problem when I build it.

node_modules/vite/node_modules/esbuild/lib/main.js:1336:21: ERROR: [plugin: vite:dep-scan] Failed to resolve entry for package "@cornerstonejs/nifti-image-loader". The package may have incorrect main/module/exports specified in its package.json.
iamiota commented 1 year ago

Add alias for it in vite.config.ts

export default defineConfig({
  resolve: {
    alias: {
      'cornerstone-nifti-image-loader': '@cornerstonejs/nifti-image-loader/dist/cornerstoneNIFTIImageLoader.min.js',
    },
  },
})

Use it with alias

import * as cornerstoneNIFTIImageLoader from 'cornerstone-nifti-image-loader'