2025-10-11 22:33:47 +08:00
|
|
|
// @ts-check
|
2025-09-29 16:33:15 +08:00
|
|
|
import { dirname, resolve } from 'path'
|
2025-10-12 01:15:14 +08:00
|
|
|
import dts from 'unplugin-dts/vite'
|
2025-09-29 16:33:15 +08:00
|
|
|
import { fileURLToPath } from 'url'
|
|
|
|
|
import { defineConfig } from 'vite'
|
2025-10-12 01:15:14 +08:00
|
|
|
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
|
2025-09-29 16:33:15 +08:00
|
|
|
|
2025-12-01 20:11:12 +08:00
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
2025-10-11 22:33:47 +08:00
|
|
|
|
2025-12-16 19:45:40 +08:00
|
|
|
// ES Module for NPM Package
|
2025-12-16 20:38:15 +08:00
|
|
|
export default defineConfig({
|
2025-12-01 20:11:12 +08:00
|
|
|
clearScreen: false,
|
2025-10-12 01:15:14 +08:00
|
|
|
plugins: [
|
2026-04-12 02:04:21 +08:00
|
|
|
dts({
|
|
|
|
|
bundleTypes: true,
|
|
|
|
|
compilerOptions: {
|
|
|
|
|
composite: true,
|
|
|
|
|
noEmit: false,
|
|
|
|
|
emitDeclarationOnly: true,
|
|
|
|
|
declaration: true,
|
|
|
|
|
},
|
|
|
|
|
}),
|
2025-10-12 01:15:14 +08:00
|
|
|
cssInjectedByJsPlugin({ relativeCSSInjection: true }),
|
|
|
|
|
],
|
|
|
|
|
publicDir: false,
|
|
|
|
|
esbuild: {
|
|
|
|
|
keepNames: true,
|
|
|
|
|
},
|
|
|
|
|
build: {
|
|
|
|
|
lib: {
|
2026-01-19 16:06:07 +08:00
|
|
|
entry: resolve(__dirname, 'src/PageAgentCore.ts'),
|
|
|
|
|
name: 'PageAgentCore',
|
|
|
|
|
fileName: 'page-agent-core',
|
2025-10-12 01:15:14 +08:00
|
|
|
formats: ['es'],
|
|
|
|
|
},
|
2025-12-16 19:45:40 +08:00
|
|
|
outDir: resolve(__dirname, 'dist', 'esm'),
|
2025-10-12 01:15:14 +08:00
|
|
|
rollupOptions: {
|
2025-12-16 01:52:15 +08:00
|
|
|
external: [
|
|
|
|
|
'chalk',
|
|
|
|
|
'zod',
|
2026-03-05 19:13:18 +08:00
|
|
|
'zod/v4',
|
2025-12-16 01:52:15 +08:00
|
|
|
// all the internal packages
|
|
|
|
|
/^@page-agent\//,
|
|
|
|
|
],
|
2025-10-12 01:15:14 +08:00
|
|
|
},
|
|
|
|
|
minify: false,
|
|
|
|
|
sourcemap: true,
|
|
|
|
|
cssCodeSplit: true,
|
|
|
|
|
},
|
|
|
|
|
define: {
|
|
|
|
|
'process.env.NODE_ENV': '"production"',
|
|
|
|
|
},
|
2025-12-16 20:38:15 +08:00
|
|
|
})
|