-
Notifications
You must be signed in to change notification settings - Fork 4
/
vite.config.ts
48 lines (45 loc) · 1.15 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
/// <reference types="vitest" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { resolve } from 'path';
import dts from 'vite-plugin-dts';
import { copyFileSync } from 'node:fs';
const OUT_DIR = resolve(__dirname, 'dist');
export default defineConfig({
plugins: [
react(),
dts({
rollupTypes: true,
afterBuild: () => {
const esmTypeDefinitions = resolve(OUT_DIR, 'index.d.ts');
const cjsTypeDefinitions = resolve(OUT_DIR, 'index.d.cts');
copyFileSync(esmTypeDefinitions, cjsTypeDefinitions);
},
}),
],
build: {
outDir: OUT_DIR,
emptyOutDir: true,
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'auth-react-router',
formats: ['es', 'umd'],
fileName: `index`,
},
rollupOptions: {
external: ['react', 'react-router', 'react-router-dom'],
output: {
globals: {
react: 'React',
'react-router': 'ReactRouter',
'react-router-dom': 'ReactRouterDOM',
},
},
},
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['src/test/setup.ts']
},
});