forked from akonan/wiremd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
63 lines (62 loc) · 1.76 KB
/
Copy pathvite.config.ts
File metadata and controls
63 lines (62 loc) · 1.76 KB
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
import { defineConfig } from 'vite';
import { resolve, isAbsolute } from 'path';
import dts from 'vite-plugin-dts';
export default defineConfig({
build: {
lib: {
entry: {
index: resolve(__dirname, 'src/index.ts'),
parser: resolve(__dirname, 'src/parser/index.ts'),
renderer: resolve(__dirname, 'src/renderer/index.ts'),
'cli/index': resolve(__dirname, 'src/cli/index.ts'),
},
formats: ['es', 'cjs'],
fileName: (format, entryName) => {
const ext = format === 'es' ? 'js' : 'cjs';
return `${entryName}.${ext}`;
},
},
rollupOptions: {
external: (id) => {
if (/^node:/.test(id)) return true;
const nodeBuiltins = [
'fs', 'path', 'http', 'https', 'crypto', 'os', 'stream',
'util', 'events', 'buffer', 'process', 'url', 'querystring',
'fs/promises'
];
if (nodeBuiltins.includes(id)) return true;
// Don't externalize entry files / relative imports / @/ aliases.
// Use isAbsolute() so Windows paths (D:\...) are recognized too.
if (id.startsWith('.') || id.startsWith('@/') || isAbsolute(id)) return false;
// Everything else is a bare specifier (npm package) — externalize.
return true;
},
output: {
exports: 'named',
},
},
sourcemap: true,
minify: false,
},
plugins: [
dts({
include: ['src/**/*.ts'],
exclude: ['src/**/*.test.ts', 'src/**/*.spec.ts'],
}),
],
test: {
globals: true,
environment: 'node',
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
exclude: [
'node_modules/',
'dist/',
'tests/',
'**/*.test.ts',
'**/*.spec.ts',
],
},
},
});