-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
57 lines (52 loc) · 1.33 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
import react from '@vitejs/plugin-react';
import { basename, resolve } from 'path';
import { readPackage } from 'read-pkg';
import { type RollupOptions } from 'rollup';
import dts from 'vite-plugin-dts';
import { defineConfig } from 'vitest/config';
const directory = process.cwd();
const packageName = basename(directory);
const packageJson = await readPackage({ cwd: directory });
const rollupOptions: RollupOptions = {
external: [
...Object.keys(packageJson?.dependencies ?? {}),
...Object.keys(packageJson?.peerDependencies ?? {}),
/@arcgis\/core\/.*/,
'react/jsx-runtime',
/@firebase\/.*/,
/firebase\/.*/,
],
output: {
globals: {
react: 'React',
tailwindcss: 'tailwindcss',
},
},
};
if (packageName === 'utilities') {
rollupOptions.input = {
main: resolve(directory, 'src/index.js'),
hooks: resolve(directory, 'src/hooks/index.js'),
};
}
const config = defineConfig({
plugins: [react(), dts({ include: ['src'] })],
build: {
lib: {
entry: resolve(directory, 'src/index.js'),
formats: ['es'],
name: `@ugrc/${packageName}`,
fileName: (format) => {
return `index.${format}.js`;
},
},
sourcemap: true,
emptyOutDir: true,
rollupOptions,
},
test: {
environment: 'jsdom',
globals: true,
},
});
export default config;