-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
58 lines (55 loc) · 1.66 KB
/
vite.config.ts
File metadata and controls
58 lines (55 loc) · 1.66 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
import { defineConfig, Plugin } from 'vite'
import dts from 'vite-plugin-dts'
import { resolve } from 'path'
import { fileURLToPath, URL } from 'node:url'
import { exec } from 'child_process'
import { promisify } from 'util'
const execAsync = promisify(exec)
// Custom Tailwind CSS builder plugin
const tailwindCssPlugin = (): Plugin => ({
name: 'tailwind-css-builder',
async generateBundle() {
console.log('Building Tailwind CSS...')
try {
await execAsync('npx @tailwindcss/cli -i ./src/index.css -o ./dist/style.css --minify')
console.log('✓ Tailwind CSS built successfully')
} catch (error) {
console.error('✗ Failed to build Tailwind CSS:', error)
throw error
}
}
})
export default defineConfig({
plugins: [
dts({
insertTypesEntry: true,
include: ['src/**/*'],
exclude: ['src/**/*.stories.tsx', 'src/**/*.test.tsx', 'src/test/**/*']
}),
tailwindCssPlugin()
],
build: {
emptyOutDir: true, // Enable directory cleaning
lib: {
entry: resolve(fileURLToPath(new URL('.', import.meta.url)), 'src/index.ts'),
name: 'RsTree',
formats: ['es', 'cjs'],
fileName: (format) => `index.${format === 'es' ? 'js' : 'cjs'}`
},
rollupOptions: {
external: ['react', 'react-dom', '@tanstack/react-virtual', 'lucide-react', 'clsx', 'tailwind-merge'],
output: {
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'@tanstack/react-virtual': 'ReactVirtual',
'lucide-react': 'LucideReact',
'clsx': 'clsx',
'tailwind-merge': 'twMerge'
}
}
},
sourcemap: true,
minify: 'esbuild'
}
})