From 8da03630893d6fc0c268b16490f50f14f78b6c51 Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Wed, 18 Mar 2026 20:30:45 +0100 Subject: [PATCH] feat: add Vite library build config with dts generation Separate vite.lib.config.ts for library mode builds: - ES module output (index.es.js) with react/react-dom externalized - Consolidated type declarations via rollupTypes (index.es.d.ts) - CSS Modules with debuggable scoped names (cameleer_ prefix) - Deterministic output filenames (style.css, index.es.js) Co-Authored-By: Claude Opus 4.6 (1M context) --- tsconfig.node.json | 2 +- vite.lib.config.ts | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 vite.lib.config.ts diff --git a/tsconfig.node.json b/tsconfig.node.json index db0becc..9da9bdd 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -20,5 +20,5 @@ "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true }, - "include": ["vite.config.ts"] + "include": ["vite.config.ts", "vite.lib.config.ts"] } diff --git a/vite.lib.config.ts b/vite.lib.config.ts new file mode 100644 index 0000000..c2fefe7 --- /dev/null +++ b/vite.lib.config.ts @@ -0,0 +1,34 @@ +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' +import dts from 'vite-plugin-dts' +import { resolve } from 'path' + +export default defineConfig({ + plugins: [ + react(), + dts({ + include: ['src/design-system'], + exclude: ['**/*.test.tsx', '**/*.test.ts'], + outDir: 'dist', + tsconfigPath: resolve(__dirname, 'tsconfig.app.json'), + rollupTypes: true, + }), + ], + css: { + modules: { + localsConvention: 'camelCase', + generateScopedName: 'cameleer_[name]_[local]_[hash:5]', + }, + }, + build: { + lib: { + entry: resolve(__dirname, 'src/design-system/index.ts'), + formats: ['es'], + fileName: () => 'index.es.js', + cssFileName: 'style', + }, + rollupOptions: { + external: ['react', 'react-dom', 'react-router-dom', 'react/jsx-runtime'], + }, + }, +})