mm
This commit is contained in:
@@ -1,29 +1,40 @@
|
||||
import { defineConfig } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import dts from "vite-plugin-dts";
|
||||
import path from "path";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
react(),
|
||||
tailwindcss(),
|
||||
dts({
|
||||
insertTypesEntry: true,
|
||||
}),
|
||||
],
|
||||
|
||||
esbuild: false,
|
||||
// d.ts 由 tsc 完成,使用专门配置 tsconfig.build.json
|
||||
// 转换由 oxc 完成
|
||||
// 打包由 rolldown 完成
|
||||
plugins: [react(), tailwindcss()],
|
||||
|
||||
build: {
|
||||
cssMinify: false,
|
||||
lib: {
|
||||
entry: path.resolve(__dirname, "src/index.ts"),
|
||||
name: "DefgovUIWebTw",
|
||||
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",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
sourcemap: true,
|
||||
cssCodeSplit: true,
|
||||
emptyOutDir: true, // 防止旧产物残留
|
||||
sourcemap: true, // 方便调试
|
||||
cssCodeSplit: false, // 合并成一个css文件
|
||||
outDir: "dist", // 专管打包输出目录,tsconfig.build.json 中的 outDir 管的是 d.ts 输出目录
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user