From 3f06ca3623c9248e2cf1950a7a54f13cb83382d8 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Mon, 25 Mar 2024 19:14:41 +0800 Subject: [PATCH] =?UTF-8?q?build(data-source):=20umd=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=B0=86lodash=E6=89=93=E5=8C=85=E8=BF=9B?= =?UTF-8?q?=E5=8E=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/data-source/package.json | 2 +- packages/data-source/vite.config.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) 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)); }, }, }, -}); +}));