Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
57 lines (56 loc) · 2.16 KB
/
Copy pathvite.config.ts
File metadata and controls
57 lines (56 loc) · 2.16 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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { resolve } from 'path'
import dts from 'vite-plugin-dts'
export default defineConfig({
plugins: [
react(),
dts({
include: ['src'],
insertTypesEntry: true,
pathsToAliases: false,
// API Extractor reads tsconfig `paths` itself: unset them so core stays an external import.
bundleTypes: {
extractorConfig: { compiler: { overrideTsconfig: { compilerOptions: { paths: null } } } },
},
}),
],
build: {
// Terser over Vite's default esbuild minifier: negligible difference on the UMD build, but
// ~16% smaller gzipped on the ES build specifically — the one most real consumers actually
// pull in (any bundler resolves `exports.import`/`module`, not `main`/UMD). Property mangling
// deliberately left off — safe for local variable/function names, not for object keys without
// auditing every dynamic property access first. Matches packages/vanilla's own reasoning,
// applied here too since the gain is real even without a checked-in size budget forcing it.
minify: 'terser',
lib: {
// Only the main entry point here — a UMD build (this package's `main` field, so it still
// works as a plain <script> global) can't have more than one entry point (Rollup
// restriction), so the `/theme` sub-path re-export is built by a separate
// `vite.theme.config.ts` pass instead (es+cjs only, no umd) — see that file and this
// package.json's `build` script.
entry: resolve(import.meta.dirname, 'src/index.ts'),
name: 'DataTableReact',
fileName: 'data-table-react',
formats: ['es', 'umd'],
},
rollupOptions: {
external: [
'react',
'react/jsx-runtime',
'react-dom',
'@vates/data-table-core',
'@vates/data-table-core/internal',
],
output: {
globals: {
react: 'React',
'react/jsx-runtime': 'ReactJSXRuntime',
'react-dom': 'ReactDOM',
'@vates/data-table-core': 'DataTableCore',
'@vates/data-table-core/internal': 'DataTableCore',
},
},
},
},
})