-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.lib.config.ts
More file actions
56 lines (49 loc) · 1.26 KB
/
vite.lib.config.ts
File metadata and controls
56 lines (49 loc) · 1.26 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
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import tailwindcss from '@tailwindcss/vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
const BasePath = 'src/package/rangeflow'
const isExternal = (id: string) => {
const pkg = JSON.parse(readFileSync(resolve(__dirname, 'package.json'), 'utf8'))
const dependencies = new Set<string>([
...Object.keys(pkg.dependencies ?? {}),
...Object.keys(pkg.peerDependencies ?? {})
])
for (const dependency of dependencies) {
if (id === dependency || id.startsWith(`${dependency}/`)) {
return true
}
}
return false
}
export default defineConfig({
plugins: [
react(),
tailwindcss(),
dts({
tsconfigPath: './tsconfig.lib.json',
include: [`${BasePath}/**/*`],
outDir: 'dist',
entryRoot: BasePath
})
],
publicDir: false,
build: {
outDir: 'dist',
emptyOutDir: true,
sourcemap: false,
cssCodeSplit: false,
lib: {
entry: resolve(__dirname, `${BasePath}/index.ts`),
formats: ['es'],
fileName: () => 'index.js',
cssFileName: 'style'
},
rollupOptions: {
external: isExternal,
checks: { pluginTimings: false }
}
}
})