-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathvite.config.ts
More file actions
103 lines (102 loc) · 2.7 KB
/
vite.config.ts
File metadata and controls
103 lines (102 loc) · 2.7 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import fs from "node:fs"
import { dts } from "rolldown-plugin-dts"
import path from "node:path"
import { defineConfig } from "rolldown-vite"
import tsconfigPaths from "vite-tsconfig-paths"
import babel from "vite-plugin-babel"
export default defineConfig({
define: {
"process.env.NODE_ENV": JSON.stringify("production"),
"process.env.DEV": "'false'",
},
ssr: {
noExternal: true,
resolve: {},
},
optimizeDeps: {
include: ["ink > cli-boxes"],
rollupOptions: {},
},
build: {
// enableBuildReport: true,
target: "esnext",
minify: "esbuild",
sourcemap: process.env.SOURCE_MAP === "true",
commonjsOptions: {
include: ["cli-boxes"],
extensions: [".js", ".mjs"],
transformMixedEsModules: true,
strictRequires: ["cli-boxes"],
esmExternals: true,
},
rollupOptions: {
input: {
cli: "./src/index.ts",
lib: "./src/lib.ts",
mcp: "./src/mcp.tsx",
core: "./src/core.tsx",
},
external: [
"ai",
"@ai-sdk/google",
"@ai-sdk/openai",
"@ai-sdk/anthropic",
"@vscode/ripgrep",
"@lancedb/lancedb",
"unconfig",
"cli-boxes",
"linkedom",
/node:/,
...require("repl")._builtinLibs,
],
output: {
minifyInternalExports: false,
},
onwarn(warning: any, warn: any) {
if (
warning.code === "MODULE_LEVEL_DIRECTIVE" ||
warning.code === "EVAL" ||
warning.code === "SOURCEMAP_ERROR" ||
warning.code === "UNUSED_EXTERNAL_IMPORT" ||
warning.code === "INVALID_ANNOTATION" ||
warning.code === "CIRCULAR_DEPENDENCY"
) {
return
}
warn(warning)
},
},
},
plugins: [
// dts(),
tsconfigPaths({ projects: [path.resolve(__dirname, "tsconfig.json")] }),
(babel as any)({
include: /\.tsx$/,
babelConfig: {
plugins: [
[path.resolve(__dirname, "node_modules/babel-plugin-react-compiler"), {}],
process.env.NODE_ENV === "development" && [
"@locator/babel-jsx/dist",
{
env: "development",
},
],
process.env.NODE_ENV === "development" && ["@hh.ru/babel-plugin-react-displayname"],
].filter((v) => !!v),
},
}),
{
name: "write-headers",
closeBundle() {
setTimeout(() => {
const cli = fs.readFileSync(path.resolve(__dirname, "dist/cli.js"), "utf-8")
fs.writeFileSync(path.resolve(__dirname, "dist/cli.js"), `#!/usr/bin/env node\n${cli}`)
}, 10)
},
},
],
experimental: {
enableNativePlugin: true,
skipSsrTransform: true,
},
})