-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
34 lines (30 loc) · 937 Bytes
/
build.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
const { globSync } = require('glob')
const { build } = require('vite')
const path = require('path')
const files = globSync('./**/index.ts')
.map( file => {
const dirname = path.dirname(file)
const filename = path.basename(file)
const name = path.basename(dirname)
return {
emptyOutDir: false,
target: 'es2015',
outDir: path.resolve(`./${dirname}`),
lib: {
name,
entry: `./${dirname}/${filename}`,
formats:['umd', 'esm'],
fileName: (type) => {
return type == 'umd' ? 'index.umd.js' : 'index.js'
}
},
rollupOptions: {
output: {
exports: 'named'
}
}
}
})
files.forEach( async (library) => {
await build({ build: library })
})