vite.config.ts
1 /// <reference types="vitest" /> 2 import { resolve } from 'path'; 3 import { defineConfig } from 'vite'; 4 import checker from 'vite-plugin-checker'; 5 import dts from 'vite-plugin-dts'; 6 import tsconfigPaths from 'vite-tsconfig-paths'; 7 8 export default defineConfig(({ mode }) => ({ 9 plugins: [ 10 dts({ 11 insertTypesEntry: true, 12 }), 13 checker({ 14 typescript: { buildMode: true } 15 }), 16 tsconfigPaths(), 17 ], 18 build: { 19 lib: { 20 // Could also be a dictionary or array of multiple entry points 21 entry: resolve(__dirname, 'src/index.ts'), 22 name: 'Core', 23 fileName: 'index', 24 }, 25 rollupOptions: { 26 preserveSymlinks: true, 27 external: [ 28 '@emotion/react', 29 '@emotion/styled', 30 '@helia/unixfs', 31 '@libp2p/pnet', 32 '@mui/icons-material', 33 '@mui/material', 34 '@preact/signals-react', 35 'file-type', 36 'helia', 37 'ipmc-core', 38 'ipmc-interfaces', 39 'minidenticons', 40 'multiformats', 41 'react', 42 'react-dom', 43 'shaka-player', 44 'wouter', 45 ], 46 output: { 47 // Provide global variables to use in the UMD build 48 // for externalized deps 49 globals: { 50 '@emotion/react': 'react', 51 '@emotion/styled': 'emStyled', 52 '@mui/icons-material': 'iconsMaterial', 53 '@mui/material': 'material', 54 '@preact/signals-react': 'signalsReact', 55 'file-type': 'fileType', 56 helia: 'helia', 57 react: 'React', 58 'ipmc-core': 'ipmcCore', 59 'ipmc-interfaces': 'ipmcInterfaces', 60 minidenticons: 'minidenticons', 61 'shaka-player': 'shaka', 62 wouter: 'wouter', 63 }, 64 }, 65 }, 66 emptyOutDir: mode !== 'dev', 67 sourcemap: mode == 'dev', 68 manifest: false, 69 minify: mode == 'dev' ? 'esbuild' : 'terser', 70 }, 71 test: { 72 globals: true, 73 environment: 'jsdom', 74 }, 75 }));