-
Notifications
You must be signed in to change notification settings - Fork 35
/
vite.config.ts
47 lines (42 loc) · 1.16 KB
/
vite.config.ts
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
import react from '@vitejs/plugin-react-swc'
import { preserveDirectives } from 'rollup-plugin-preserve-directives'
import { defineConfig } from 'vite'
import { dependencies, devDependencies, peerDependencies } from './package.json'
const external = [
...Object.keys(dependencies || {}),
...Object.keys(peerDependencies || {}),
...Object.keys(devDependencies || {}),
].map(name => new RegExp(`^${name}(/.*)?`))
export default defineConfig(({ mode }) => {
return {
build: {
target: 'es2020',
lib: {
entry: {
'src/index': './src/index.tsx',
'tailwind.config': './tailwind.config.ts',
},
formats: ['es', 'cjs'],
fileName: format => {
return `[name].${format}.js`
},
},
sourcemap: true,
emptyOutDir: mode === 'production',
rollupOptions: {
external,
// makes 'use client' directive work
output: {
preserveModules: true,
},
plugins: [
preserveDirectives({ suppressPreserveModulesWarning: true }) as any,
],
},
},
plugins: [react()],
test: {
environment: 'happy-dom',
},
}
})