This commit is contained in:
2026-05-16 00:51:11 +08:00
parent 92e4fd11f1
commit 0f23a8f7a0
67 changed files with 153 additions and 384 deletions

View File

@@ -1,39 +0,0 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
export default defineConfig({
// d.ts 由 tsc 完成,使用专门配置 tsconfig.build.json
// 转换由 oxc 完成
// 打包由 rolldown 完成
plugins: [react()],
build: {
cssMinify: false,
lib: {
entry: path.resolve(import.meta.dirname, "src/index.ts"),
// 不写 vite 默认是 index.mjs 和 index.js不方便识别
formats: ["es", "cjs"],
// package.json 管别人怎么使用,
// build.lib 管怎么打包,生成什么
// 如果不一致,就会报错,指向文件不存在
fileName: (format) => `index.${format}.js`,
},
rolldownOptions: {
// 避免这些被打包peerDependencies 对 rolldown 是无效的,不会自动 external
external: ["react", "react-dom", "react/jsx-runtime"],
// 专门给 UMD / IIFE 的映射表
output: {
globals: {
react: "React",
"react-dom": "ReactDOM",
},
},
},
emptyOutDir: true, // 防止旧产物残留
sourcemap: true, // 方便调试
cssCodeSplit: false, // 合并成一个css文件
outDir: "dist", // 专管打包输出目录tsconfig.build.json 中的 outDir 管的是 d.ts 输出目录
},
});