-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.mts
More file actions
93 lines (88 loc) · 2.41 KB
/
vite.config.mts
File metadata and controls
93 lines (88 loc) · 2.41 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import { defineConfig, PluginOption } from 'vite'
import react from '@vitejs/plugin-react'
import dts from 'vite-plugin-dts'
import tailwindcss from '@tailwindcss/vite'
import { resolve } from 'path'
import { visualizer } from 'rollup-plugin-visualizer';
const withReport = ['true', '1', 'yes'].some(val => process.env.BUNDLE_SIZE_VISUALIZAION === val)
const plugins = [
tailwindcss() as PluginOption,
react() as PluginOption,
dts({
insertTypesEntry: true,
include: ['src/**/*'],
exclude: ['src/**/*.test.*', 'src/**/*.spec.*', 'examples/**'],
rollupTypes: true,
}) as PluginOption
]
if (withReport) {
plugins.push(
visualizer({
template: "sunburst", // or sunburst
open: true,
gzipSize: true,
brotliSize: true,
filename: "size-analysis.html", // will be saved in project's root
})
)
}
const externals = [
'react',
'react-dom',
'@duckdb/duckdb-wasm',
'@monaco-editor/react',
'recharts',
'tokenlens',
'sql-formatter',
'use-stick-to-bottom',
'nanoid',
'embla-carousel-react',
'cmdk',
'motion',
'apache-arrow',
'sonner',
'streamdown',
'monaco-editor'
]
export default defineConfig({
plugins: plugins,
resolve: {
alias: {
'@': resolve(__dirname, './src'),
'@/components': resolve(__dirname, './src/components'),
'@/lib': resolve(__dirname, './src/lib'),
'@/utils': resolve(__dirname, './src/utils'),
'@/hooks': resolve(__dirname, './src/hooks'),
'@/types': resolve(__dirname, './src/types'),
},
},
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'BlocketherFoundationReact',
formats: ['es'], // ESM-only as required by constitution
fileName: 'foundation-react',
},
cssCodeSplit: false, // Bundle all CSS into one file
rollupOptions: {
external: (id) => externals.includes(id) || id.includes('.worker') || id.startsWith('@duckdb/duckdb-wasm/dist/duckdb-') && id.endsWith('?url'),
output: {
globals: {
react: 'React',
'react-dom': 'ReactDOM'
},
assetFileNames: (assetInfo) => {
if (assetInfo.name === 'style.css') {
return 'foundation-react.css'
}
return assetInfo.name || 'assets/[name][extname]'
},
},
},
// Optimize for browser distribution
target: 'es2020',
minify: 'esbuild',
sourcemap: false,
emptyOutDir: true,
}
})