forked from allmaps/allmaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
75 lines (71 loc) · 1.59 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { defineConfig } from 'vite'
import { exec } from 'child_process'
import ports from '../../ports.json'
// TODO: move to @allmaps/stdlib?
const dts = {
name: 'dts-generator',
buildEnd: (error) => {
if (!error) {
return new Promise((resolve, reject) => {
// TODO: npm or pnpm?
exec('npm run build:types', (err) =>
err ? reject(err) : resolve()
)
})
}
}
}
/** @type {import('vite').UserConfig} */
export default defineConfig({
server: {
port: ports.render
},
build: {
target: 'es2020',
sourcemap: true,
emptyOutDir: false,
// minify: false,
lib: {
entry: './src/index.ts',
name: 'Allmaps',
fileName: (format) => {
if (format === 'umd') {
return `index.cjs`
}
return `index.js`
},
formats: ['es', 'umd']
},
rollupOptions: {
external: [
'@allmaps/annotation',
'@allmaps/id',
'@allmaps/iiif-parser',
'@allmaps/transform',
'@allmaps/stdlib',
'earcut',
'potpack',
'rbush'
],
output: {
globals: {
'@allmaps/annotation': '@allmaps/annotation',
'@allmaps/id': '@allmaps/id',
'@allmaps/iiif-parser': '@allmaps/iiif-parser',
'@allmaps/transform': '@allmaps/transform',
'@allmaps/stdlib': '@allmaps/stdlib',
rbush: 'rbush',
potpack: 'potpack',
earcut: 'earcut'
}
}
}
},
optimizeDeps: {
esbuildOptions: {
target: 'es2020'
}
},
base: '',
plugins: [dts]
})