43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { dirname, resolve } from "node:path";
|
||
import { fileURLToPath } from "node:url";
|
||
import { defineConfig } from "vite";
|
||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||
|
||
// 声明文件单独由 `tsc -p tsconfig.dts.json` 产出(比 vite-plugin-dts 快一个数量级)
|
||
export default defineConfig({
|
||
build: {
|
||
lib: {
|
||
entry: resolve(__dirname, "src/index.ts"),
|
||
formats: ["es"],
|
||
fileName: "index",
|
||
},
|
||
rollupOptions: {
|
||
external: [
|
||
"@app/danmaku",
|
||
"@app/dao",
|
||
"@app/db",
|
||
"@app/models",
|
||
"@app/types",
|
||
"@trpc/server",
|
||
"drizzle-orm",
|
||
// webdav 的 createReadStream 依赖 Node stream;打成 bundle 会把
|
||
// `import Stream from "stream"` 掏成空模块,导致 PassThrough is not a constructor
|
||
"webdav",
|
||
"stream",
|
||
/node:.*/,
|
||
],
|
||
output: {
|
||
entryFileNames: "[name].js",
|
||
chunkFileNames: "[name].js",
|
||
},
|
||
},
|
||
// 只清 JS 产物:若 emptyOutDir=true 会先删掉 tsc 刚写的 .d.ts(构建顺序是 vite → tsc)
|
||
outDir: "dist",
|
||
emptyOutDir: false,
|
||
commonjsOptions: {
|
||
transformMixedEsModules: true,
|
||
},
|
||
},
|
||
});
|