-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.library.js
More file actions
67 lines (65 loc) · 1.85 KB
/
Copy pathvite.config.library.js
File metadata and controls
67 lines (65 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import dts from 'vite-plugin-dts'
import path from 'path'
import { fileURLToPath } from 'url'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
// Library build configuration
export default defineConfig({
plugins: [
react(),
dts({
insertTypesEntry: true,
include: ['src/recordpanel/**/*'],
exclude: ['src/recordpanel/**/*.test.*', 'src/recordpanel/**/*.spec.*'],
outDir: 'dist',
})
],
build: {
lib: {
entry: path.resolve(__dirname, 'src/recordpanel/index.ts'),
name: 'RecordPanel',
formats: ['es', 'cjs'],
fileName: (format) => `index.${format === 'es' ? 'mjs' : 'cjs'}`
},
rollupOptions: {
// Externalize dependencies that should be peer dependencies
external: [
'react',
'react-dom',
'react/jsx-runtime',
// Option 1: Bundle these (simpler for users)
// Option 2: Make peer deps (smaller bundle, more control)
// 'lucide-react',
// '@radix-ui/react-slot',
// 'class-variance-authority',
// 'clsx',
// 'tailwind-merge'
],
output: {
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'react/jsx-runtime': 'react/jsx-runtime'
},
// Bundle CSS separately
assetFileNames: (assetInfo) => {
if (assetInfo.name && assetInfo.name.endsWith('.css')) {
return 'styles.css'
}
return assetInfo.name || 'assets/[name][extname]'
}
}
},
// Bundle all CSS into one file
cssCodeSplit: false,
// Generate source maps for debugging
sourcemap: true,
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
},
})