mirror of
https://github.com/olehomelchenko/astrolabe.git
synced 2026-08-08 10:12:34 +00:00
69 lines
2.4 KiB
TypeScript
69 lines
2.4 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
|
import { readFileSync } from 'node:fs';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf-8')) as {
|
|
version: string;
|
|
};
|
|
|
|
export default defineConfig({
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
'@core': fileURLToPath(new URL('./src/core', import.meta.url)),
|
|
},
|
|
},
|
|
define: {
|
|
__APP_VERSION__: JSON.stringify(pkg.version),
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
// Split the heavy vendors so the chunk graph stays legible and the PWA
|
|
// can precache/update them independently of app code. Monaco and the
|
|
// Vega stack are each multi-MB; isolating them keeps app rebuilds small.
|
|
manualChunks: {
|
|
monaco: ['monaco-editor'],
|
|
vega: ['vega', 'vega-lite', 'vega-embed'],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
plugins: [
|
|
react(),
|
|
VitePWA({
|
|
registerType: 'prompt',
|
|
includeAssets: ['favicon.svg'],
|
|
manifest: {
|
|
name: 'Astrolabe',
|
|
short_name: 'Astrolabe',
|
|
description: 'A browser-based snippet manager for Vega-Lite visualizations.',
|
|
theme_color: '#1a1a2e',
|
|
background_color: '#ffffff',
|
|
display: 'standalone',
|
|
// TODO: theme_color/background_color are stale placeholders — '#1a1a2e' was
|
|
// the old --color-text hex, retired by the M1.5 token rename. Re-pick from
|
|
// the settled palette (and reconcile with light/dark) when icons land.
|
|
icons: [],
|
|
},
|
|
workbox: {
|
|
// Workbox's default globPatterns omit woff2; add it so the self-hosted
|
|
// Plex fonts are precached too (offline is a core requirement — without
|
|
// this the first offline load silently falls back to system fonts).
|
|
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
|
|
// Monaco and Vega vendor chunks exceed Workbox's 2 MiB default; raise the
|
|
// ceiling so the whole app (offline is a core requirement) is precached.
|
|
maximumFileSizeToCacheInBytes: 6 * 1024 * 1024,
|
|
},
|
|
}),
|
|
],
|
|
// Vitest config (shares this file)
|
|
test: {
|
|
globals: true,
|
|
environment: 'happy-dom',
|
|
include: ['src/**/*.test.{ts,tsx}'],
|
|
},
|
|
} as Parameters<typeof defineConfig>[0]);
|