-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathvite.config.ts
More file actions
41 lines (36 loc) · 1014 Bytes
/
vite.config.ts
File metadata and controls
41 lines (36 loc) · 1014 Bytes
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
import { readFileSync } from 'node:fs';
import { builtinModules } from 'node:module';
import { defineConfig } from 'vite';
type PackageJsonLike = {
dependencies?: Record<string, string>;
};
const pkg = JSON.parse(
readFileSync(new URL('./package.json', import.meta.url), 'utf-8')
) as PackageJsonLike;
const externals = Object.keys(pkg.dependencies ?? {});
const builtins = new Set([...builtinModules, ...builtinModules.map((m) => `node:${m}`)]);
export default defineConfig({
build: {
outDir: 'dist',
emptyOutDir: true,
sourcemap: true,
minify: false,
target: 'node20',
lib: {
entry: './src/index.ts',
formats: ['es', 'cjs'],
fileName: (format) => (format === 'es' ? 'cli.mjs' : 'cli.js'),
},
rollupOptions: {
external(id) {
if (builtins.has(id)) {
return true;
}
return externals.some((ext) => id === ext || id.startsWith(`${ext}/`));
},
output: {
exports: 'named',
},
},
},
});