build(data-source): umd构建版本将lodash打包进去

This commit is contained in:
roymondchen 2024-03-25 19:14:41 +08:00
parent a4fc95775e
commit 3f06ca3623
2 changed files with 6 additions and 3 deletions

View File

@ -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"
},

View File

@ -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));
},
},
},
});
}));