Files
yaak-mountain-loop/src-web/vite.config.ts
Gregory Schier 49659a3da9 Migrate to Vite+ (vite-plus) unified toolchain
Replace Vite/Vitest with vite-plus, update WASM loading to native Vite 8
?init pattern, switch React compiler to @rolldown/plugin-babel, and
migrate git hooks from husky to vite-hooks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 07:23:11 -07:00

61 lines
1.7 KiB
TypeScript

// @ts-ignore
import { tanstackRouter } from '@tanstack/router-plugin/vite';
import babel from '@rolldown/plugin-babel';
import react, { reactCompilerPreset } from '@vitejs/plugin-react';
import { createRequire } from 'node:module';
import path from 'node:path';
import { defineConfig, normalizePath } from 'vite-plus';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import svgr from 'vite-plugin-svgr';
const require = createRequire(import.meta.url);
const cMapsDir = normalizePath(
path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps'),
);
const standardFontsDir = normalizePath(
path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'standard_fonts'),
);
// https://vitejs.dev/config/
export default defineConfig(
{
plugins: [
tanstackRouter({
target: 'react',
routesDirectory: './routes',
generatedRouteTree: './routeTree.gen.ts',
autoCodeSplitting: true,
}),
svgr(),
react(),
babel({
presets: [reactCompilerPreset()],
}),
viteStaticCopy({
targets: [
{ src: cMapsDir, dest: '' },
{ src: standardFontsDir, dest: '' },
],
}),
],
build: {
sourcemap: true,
outDir: '../dist',
emptyOutDir: true,
rolldownOptions: {
output: {
// Make chunk names readable
chunkFileNames: 'assets/chunk-[name]-[hash].js',
entryFileNames: 'assets/entry-[name]-[hash].js',
assetFileNames: 'assets/asset-[name]-[hash][extname]',
},
},
},
clearScreen: false,
server: {
port: parseInt(process.env.YAAK_DEV_PORT ?? '1420', 10),
strictPort: true,
},
envPrefix: ['VITE_', 'TAURI_'],
});