feat: init

This commit is contained in:
Simon
2025-09-29 16:33:15 +08:00
parent e8041e0582
commit 847620b5e8
98 changed files with 20166 additions and 0 deletions

48
vite.lib.config.ts Normal file
View File

@@ -0,0 +1,48 @@
import react from '@vitejs/plugin-react-swc'
import { dirname, resolve } from 'path'
import { fileURLToPath } from 'url'
import { defineConfig } from 'vite'
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
// Library build configuration
export default defineConfig({
plugins: [react(), cssInjectedByJsPlugin({ relativeCSSInjection: true })],
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
publicDir: false,
esbuild: {
// 禁用严格的未使用变量检查
keepNames: true,
},
build: {
lib: {
entry: resolve(__dirname, 'src/entry.ts'),
name: 'PageAgent',
fileName: 'page-agent',
formats: ['umd', 'es'],
},
outDir: resolve(__dirname, 'dist', 'lib'),
rollupOptions: {
// ESM 包 应该 external但是 UMD 时不能 external
// @TODO 分成两份配置
// external: ['@ai-sdk/openai', 'ai', 'ai-motion', 'chalk', 'zod'],
output: {
globals: {
// 定义全局变量映射
},
},
},
// minify: 'terser',
// sourcemap: true,
},
define: {
// 替换环境变量
'process.env.NODE_ENV': '"production"',
},
})