Files
boos e0a5f57793 feat(desktop): embed BoosAPI Desktop client as a subproject
Vendor the rebranded BoosAPI Desktop client (Tauri + Vue) into metapi as
a monorepo subdirectory under desktop/. Source only — node_modules,
dist, Cargo target and the upstream .git history are excluded.

desktop/ keeps its own independent Cargo workspace (desktop/src-tauri
with crates/*); it is not part of the backend boosapi crate, so a
`cargo check` at the metapi root still compiles only the backend. Build
the desktop app from desktop/src-tauri per desktop/README.md.

Note: app icons are still placeholder assets pending the final BoosAPI
logo. The updater signing keys live outside the repo and are not
included.
2026-06-22 11:32:57 +08:00

118 lines
3.2 KiB
TypeScript

import { resolve } from 'node:path'
import process from 'node:process'
import react from '@vitejs/plugin-react-swc'
import { visualizer } from 'rollup-plugin-visualizer'
import UnpluginClassExtractor from 'unplugin-class-extractor/vite'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import { name } from './package.json'
export default defineConfig(({ mode }) => {
const base = mode === 'npm' ? '' : '/'
const plugins = [react()]
if (mode === 'npm') {
plugins.push(
dts({
outDir: 'dist/types',
insertTypesEntry: true,
// Use a build-only tsconfig without workspace path aliases, otherwise
// declaration output can rewrite workspace deps into relative paths.
tsconfigPath: './tsconfig.build.json',
}),
UnpluginClassExtractor({
output: 'dist/tailwind.ts',
include: [/\/src\/.*\.(?:ts|tsx)(\?.*)?$/],
}) as any,
)
if (process.env.ANALYZE === 'true') {
plugins.push(
visualizer({ filename: 'bundle-visualizer.html', gzipSize: true, brotliSize: true }) as any,
)
}
}
return {
base,
plugins,
css: {
postcss: './postcss.config.cjs',
},
worker: {
format: 'es',
rollupOptions: {
// Keep heavy optional peer deps out of the published worker bundles.
// Consumers bundling `markstream-react/workers/*?worker` will still
// bundle these as needed in their own app build.
external: [
'katex',
'katex/contrib/mhchem',
'mermaid',
],
output: {
entryFileNames: 'workers/[name].js',
chunkFileNames: 'workers/[name].js',
assetFileNames: 'workers/[name][extname]',
},
},
},
build: {
target: 'es2019',
cssTarget: 'chrome80',
sourcemap: false,
minify: 'terser',
terserOptions: {
compress: {
ecma: 2019,
drop_console: false,
drop_debugger: true,
pure_funcs: ['console.log'],
passes: 2,
},
mangle: {
safari10: true,
},
format: {
comments: false,
// Strip /*#__PURE__*/ annotations to avoid Rollup warnings in consumers.
preserve_annotations: false,
ecma: 2019,
},
},
lib: {
entry: {
index: resolve(__dirname, 'src/index.ts'),
next: resolve(__dirname, 'src/next.ts'),
server: resolve(__dirname, 'src/server.ts'),
},
name,
fileName: (_, entryName) => `${entryName}.js`,
formats: ['es'],
},
rollupOptions: {
external: [
'node:module',
'react',
'react-dom',
'react/jsx-runtime',
'react/jsx-dev-runtime',
'katex',
'katex/contrib/mhchem',
'mermaid',
'stream-monaco',
'stream-markdown',
'stream-markdown-parser',
'@antv/infographic',
'@terrastruct/d2',
'@floating-ui/dom',
],
output: {
banner(chunk) {
return chunk.isEntry && chunk.name === 'next'
? '\'use client\';'
: ''
},
},
},
},
}
})