56 lines
2.3 KiB
TypeScript
56 lines
2.3 KiB
TypeScript
import { defineConfig } from 'vitest/config'
|
|
import react from '@vitejs/plugin-react'
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
import path from 'node:path'
|
|
import fs from 'node:fs'
|
|
|
|
const monacoEditorPath = path.resolve(
|
|
__dirname,
|
|
'../node_modules/.pnpm/monaco-editor@0.55.1/node_modules/monaco-editor',
|
|
);
|
|
|
|
// Resolve a @bytelyst/* package: prefer web/node_modules, fall back to vendor/
|
|
function bytelystAlias(pkg: string): string {
|
|
const nmPath = path.resolve(__dirname, 'node_modules/@bytelyst', pkg);
|
|
const vendorPath = path.resolve(__dirname, '../vendor/bytelyst', pkg);
|
|
if (fs.existsSync(nmPath)) return nmPath;
|
|
if (fs.existsSync(vendorPath)) return vendorPath;
|
|
return nmPath; // let Vite surface the missing-module error
|
|
}
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
tailwindcss(),
|
|
],
|
|
// Shared files (../shared/*.ts) live outside web/ so Vite resolves their imports
|
|
// from the repo root where @bytelyst/* are not installed. Redirect all @bytelyst/*
|
|
// imports first to web/node_modules, then fall back to the monorepo vendor/ dir.
|
|
resolve: {
|
|
// Deduplicate React so the vendored react-auth dist resolves the same react instance
|
|
dedupe: ['react', 'react-dom', 'react/jsx-runtime', 'react-router-dom'],
|
|
alias: [
|
|
// Vendor packages that live only in vendor/ (not in web/node_modules/)
|
|
{ find: '@bytelyst/api-client', replacement: bytelystAlias('api-client') },
|
|
{ find: '@bytelyst/errors', replacement: bytelystAlias('errors') },
|
|
// Monaco is an explicit web dependency, but this workspace often runs
|
|
// against pnpm's root store without a web/node_modules symlink when the
|
|
// private mobile registry is unavailable. Keep local worker imports
|
|
// resolvable for Vite in that partially installed state.
|
|
{ find: /^monaco-editor$/, replacement: monacoEditorPath },
|
|
{ find: /^monaco-editor\/(.+)/, replacement: `${monacoEditorPath}/$1` },
|
|
// General catch-all: every other @bytelyst/* → web/node_modules
|
|
{
|
|
find: /^@bytelyst\/(.+)/,
|
|
replacement: path.resolve(__dirname, 'node_modules/@bytelyst/$1'),
|
|
},
|
|
],
|
|
},
|
|
test: {
|
|
environment: 'jsdom',
|
|
setupFiles: ['./src/test/setup.ts'],
|
|
include: ['src/**/*.test.ts', 'src/**/*.test.tsx', 'src/**/*.dom.test.tsx'],
|
|
},
|
|
})
|