diff --git a/packages/data-source/package.json b/packages/data-source/package.json index a6b80178..a2c4fd44 100644 --- a/packages/data-source/package.json +++ b/packages/data-source/package.json @@ -18,7 +18,7 @@ }, "license": "Apache-2.0", "scripts": { - "build": "npm run build:type && vite build", + "build": "npm run build:type && vite build --mode=es && vite build --mode=umd", "build:type": "npm run clear:type && tsc --declaration --emitDeclarationOnly --project tsconfig.build.json && tsc-alias -p tsconfig.build.json", "clear:type": "rimraf ./types" }, diff --git a/packages/data-source/vite.config.ts b/packages/data-source/vite.config.ts index 26e4bd4b..6766d03f 100644 --- a/packages/data-source/vite.config.ts +++ b/packages/data-source/vite.config.ts @@ -22,7 +22,7 @@ import { defineConfig } from 'vite'; import pkg from './package.json'; -export default defineConfig({ +export default defineConfig(({ mode }) => ({ resolve: { alias: process.env.NODE_ENV === 'production' @@ -48,8 +48,11 @@ export default defineConfig({ rollupOptions: { // 确保外部化处理那些你不想打包进库的依赖 external(id: string) { + if (mode === 'umd' && id === 'lodash-es') { + return false; + } return Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id)); }, }, }, -}); +}));