39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import react, { reactCompilerPreset } from "@vitejs/plugin-react";
|
|
import babel from "@rolldown/plugin-babel";
|
|
import { defineConfig } from "vite";
|
|
import { resolve } from "path";
|
|
import pkg from "./package.json" with { type: "json" };
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
devtools: {
|
|
// Remove this `apply` property to enable devtools for build as well
|
|
apply: "serve",
|
|
},
|
|
plugins: [react(), babel({ presets: [reactCompilerPreset()] })],
|
|
|
|
build: {
|
|
// Must write, vite/css-minify cannot recognize some ruler
|
|
cssMinify: false,
|
|
lib: {
|
|
entry: resolve(import.meta.dirname, "src/index.ts"),
|
|
name: "ui-react",
|
|
formats: ["es", "umd"],
|
|
fileName: (format) => {
|
|
return `index.${format}.js`;
|
|
},
|
|
cssFileName: "index",
|
|
},
|
|
rolldownOptions: {
|
|
external: ["react/jsx-runtime", ...Object.keys(pkg.peerDependencies)],
|
|
output: {
|
|
// 为 UMD 构建提供 global 变量
|
|
globals: {
|
|
react: "React",
|
|
"react-dom": "ReactDOM",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|