-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathvite.config.ts
54 lines (51 loc) · 1.52 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
import { resolve } from 'path'
import { defineConfig, LibraryFormats, UserConfig } from 'vite'
import glsl from 'vite-plugin-glsl'
import dts from 'vite-plugin-dts'
// eslint-disable-next-line import/no-default-export
export default defineConfig(() => {
const config: UserConfig = {
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'Cosmos',
formats: ['es', 'umd'] as LibraryFormats[],
fileName: (format): string => format === 'umd' ? 'index.min.js' : 'index.js',
},
sourcemap: true,
minify: true,
rollupOptions: {
external: ['d3-array', 'd3-color', 'd3-drag', 'd3-ease', 'd3-scale', 'd3-selection', 'd3-transition', 'd3-zoom', 'regl'],
output: {
globals: {
'd3-selection': 'd3',
'd3-ease': 'd3',
regl: 'createREGL',
'd3-color': 'd3',
'd3-scale': 'd3',
'd3-array': 'd3',
'gl-matrix': 'glMatrix',
random: 'random',
'd3-zoom': 'd3',
'd3-drag': 'd3',
'd3-transition': 'd3',
},
},
},
},
plugins: [
glsl(),
dts(),
],
resolve: {
alias: {
'@/graph': resolve(__dirname, 'src/'),
'@cosmograph/cosmos': resolve(__dirname, 'src/'),
},
},
}
if (config?.build?.lib && config.build.rollupOptions && config.build.lib.formats && config.build.lib.formats.includes('umd')) {
delete config.build.rollupOptions.external
}
return config
})