-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
52 lines (51 loc) · 1.26 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
import { defineConfig } from 'vite';
import path from 'path';
import { configDefaults } from 'vitest/config';
export default defineConfig({
resolve: {
alias: {
'@': path.resolve(__dirname, './src')
}
},
build: {
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'SheetSense',
formats: ['iife', 'cjs'],
fileName: (format) => {
if (format === 'iife') return 'sheetsense.browser.js';
return 'sheetsense.node.js';
}
},
sourcemap: true,
outDir: 'dist',
emptyOutDir: true,
rollupOptions: {
// Only mark dependencies as external for CJS build
external: (id) => {
if (id === 'zod' || id === 'xlsx') {
// Check the current format being built
const currentFormat = process.env.FORMAT;
return currentFormat === 'cjs';
}
return false;
},
// For IIFE build, define how external dependencies should be found in browser
output: {
globals: {
zod: 'zod',
xlsx: 'XLSX'
}
}
}
},
test: {
globals: true,
environment: 'node',
exclude: [...configDefaults.exclude, 'e2e/*'],
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html']
}
}
});