-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
78 lines (69 loc) · 1.55 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
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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import dts from 'vite-plugin-dts'
export default defineConfig({
build: {
rollupOptions: {
external: ['vue'],
output: {
globals: {
vue: 'Vue'
}
}
},
lib: {
entry: 'src/index.ts',
name: 'VueFreecaster',
formats: ['es', 'cjs', 'umd'],
fileName: (format, name) => `${name}.${extension(format)}`
}
},
plugins: [
vue(),
dts({
tsconfigPath: './tsconfig.app.json',
copyDtsFiles: true,
entryRoot: 'src',
exclude: [
'playground'
],
beforeWriteFile: (filePath: string, content: string) => {
const match = /\/(components|composables)\/([^\/]+?)(?:\.vue)?\.d\.ts$/.exec(filePath)
switch (match?.[1]) {
case 'components':
content = (
'/**\n' +
` * @module <${match[2]}/>\n` +
' */\n\n' +
content
)
break
case 'composables':
content = (
'/**\n' +
` * @module use${match[2][0].toUpperCase() + match[2].slice(1)}\n` +
' */\n\n' +
content
)
break
}
return {
filePath,
content
}
}
})
]
})
function extension(format: string): string {
switch (format) {
case 'es':
return 'mjs'
case 'cjs':
return 'cjs'
case 'umd':
return 'js'
default:
return `${format}.js`
}
}