kerf-engine/app/vite.embed.config.ts
jlightner 7fbd909646 feat: Added setEngineBaseUrl() to engine API client, created <kerf-embe…
- "app/src/api/engine.ts"
- "app/src/embed.tsx"
- "app/vite.embed.config.ts"
- "app/tsconfig.node.json"

GSD-Task: S03/T01
2026-03-26 06:59:49 +00:00

42 lines
1.3 KiB
TypeScript

/// <reference types="vite/client" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { resolve } from 'path';
/**
* Vite library-mode config for the <kerf-embed> Web Component.
*
* Bundles everything (React, Konva, opentype.js) into a self-contained
* output — nothing is externalized. Outputs ES module + IIFE formats.
*/
export default defineConfig({
plugins: [react()],
build: {
outDir: 'dist-embed',
emptyOutDir: true,
lib: {
entry: resolve(__dirname, 'src/embed.tsx'),
name: 'KerfEmbed',
formats: ['es', 'iife'],
fileName: (format) => {
if (format === 'es') return 'kerf-embed.js';
return 'kerf-embed.iife.js';
},
},
// Don't inline CSS — extract to style.css for optional manual loading
cssCodeSplit: false,
rollupOptions: {
// Explicitly empty to prevent any auto-externalization
external: [],
output: {
// Prevent chunk splitting — single self-contained bundle
codeSplitting: false,
// Name the CSS output predictably
assetFileNames: (assetInfo) => {
if (assetInfo.names?.[0]?.endsWith('.css')) return 'style.css';
return assetInfo.names?.[0] ?? '[name][extname]';
},
},
},
},
});