-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
43 lines (41 loc) · 963 Bytes
/
vite.config.ts
File metadata and controls
43 lines (41 loc) · 963 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
42
43
import { builtinModules } from "node:module";
import path from "node:path";
import { defineConfig } from "vite";
const builtins = new Set([
...builtinModules,
...builtinModules.map((moduleName) => `node:${moduleName}`),
]);
export default defineConfig({
resolve: {
alias: {
"@": path.resolve(import.meta.dirname, "src"),
},
},
build: {
target: "node24",
emptyOutDir: true,
lib: {
entry: path.resolve(import.meta.dirname, "src/index.ts"),
formats: ["cjs"],
fileName: () => "index.js",
},
rollupOptions: {
external: (id) => builtins.has(id),
output: {
entryFileNames: "index.js",
},
},
},
plugins: [
{
name: "emit-commonjs-package-type",
generateBundle() {
this.emitFile({
type: "asset",
fileName: "package.json",
source: `${JSON.stringify({ type: "commonjs" }, null, 2)}\n`,
});
},
},
],
});