mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-24 10:21:15 +01:00
Adds sourcemap: true to Vite build configuration to generate external source map files (.map) alongside JavaScript bundles. This enables debugging of production builds with original source code while keeping source maps separate from the main bundle files. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
62 lines
1.7 KiB
TypeScript
62 lines
1.7 KiB
TypeScript
// @ts-ignore
|
|
import { tanstackRouter } from '@tanstack/router-plugin/vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import { createRequire } from 'node:module';
|
|
import path from 'node:path';
|
|
import { defineConfig, normalizePath } from 'vite';
|
|
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
|
import svgr from 'vite-plugin-svgr';
|
|
import topLevelAwait from 'vite-plugin-top-level-await';
|
|
import wasm from 'vite-plugin-wasm';
|
|
|
|
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(async () => {
|
|
return {
|
|
plugins: [
|
|
wasm(),
|
|
tanstackRouter({
|
|
target: 'react',
|
|
routesDirectory: './routes',
|
|
generatedRouteTree: './routeTree.gen.ts',
|
|
autoCodeSplitting: true,
|
|
}),
|
|
svgr(),
|
|
react(),
|
|
topLevelAwait(),
|
|
viteStaticCopy({
|
|
targets: [
|
|
{ src: cMapsDir, dest: '' },
|
|
{ src: standardFontsDir, dest: '' },
|
|
],
|
|
}),
|
|
],
|
|
build: {
|
|
sourcemap: true,
|
|
outDir: '../dist',
|
|
emptyOutDir: true,
|
|
rollupOptions: {
|
|
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_'],
|
|
};
|
|
});
|