40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { fileURLToPath, URL } from "node:url";
|
||
import { defineConfig } from "vite";
|
||
import vue from "@vitejs/plugin-vue";
|
||
|
||
// 两种构建:
|
||
// - 默认(`vite build` / `vite dev`):独立 demo 应用(index.html)。
|
||
// - `--mode lib`(`pnpm build:lib`):组件库,产出 ESM + UMD + 一个 style.css,
|
||
// 供其它 Vue 项目 `import { ParallelAgentsPanel } from "parallel-agents-vue"`。
|
||
export default defineConfig(({ mode }) => {
|
||
const isLib = mode === "lib";
|
||
return {
|
||
plugins: [vue()],
|
||
resolve: {
|
||
alias: { "@": fileURLToPath(new URL("./src", import.meta.url)) },
|
||
},
|
||
server: { port: 5183 },
|
||
build: isLib
|
||
? {
|
||
lib: {
|
||
entry: fileURLToPath(new URL("./src/index.ts", import.meta.url)),
|
||
name: "ParallelAgentsVue",
|
||
fileName: "parallel-agents-vue",
|
||
},
|
||
rollupOptions: {
|
||
// vue 由宿主提供,不打进库。
|
||
external: ["vue"],
|
||
output: {
|
||
exports: "named",
|
||
globals: { vue: "Vue" },
|
||
assetFileNames: "parallel-agents-vue.[ext]",
|
||
},
|
||
},
|
||
cssCodeSplit: false,
|
||
}
|
||
: {
|
||
outDir: "dist-app",
|
||
},
|
||
};
|
||
});
|