-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.js
54 lines (46 loc) · 1.43 KB
/
vite.config.js
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
import { defineConfig } from 'vite'
import fg from 'fast-glob'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
// Defines an array of entry points to be used to search for files.
const entryPoints = [
'src/ui/**/*.js',
'src/*.js'
]
// Searches for files that match the patterns defined in the array of input points.
// Returns an array of absolute file paths.
const files = fg.sync(entryPoints, { absolute: true })
// Maps the file paths in the "files" array to an array of key-value pair.
const entities = files.map((file) => {
// Extract the part of the file path after the "src" folder and before the file extension.
const [key] = file.match(/(?<=src\/).*$/) || []
// Remove the file extension from the key.
const keyWithoutExt = key.replace(/\.[^.]*$/, '')
return [keyWithoutExt, file]
})
// Convert the array of key-value pairs to an object using the Object.fromEntries() method.
// Returns an object where each key is the file name without the extension and the value is the absolute file path.
const entries = Object.fromEntries(entities)
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': resolve(__dirname, './src/'),
}
},
build: {
outDir: 'dist',
lib: {
entry: entries,
formats: ['es']
},
rollupOptions: {
external: ['vue','@headlessui/vue'],
output: {
globals: {
vue: 'Vue',
}
},
}
}
})