mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-10 14:13:01 +08:00
build(util): umd版本将lodash-es打进去
This commit is contained in:
parent
3c167f3b54
commit
5a5288c9da
@ -18,7 +18,7 @@
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"build": "npm run build:type && vite build",
|
||||
"build": "rimraf ./dist && 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",
|
||||
"clear:type": "rimraf ./types"
|
||||
},
|
||||
|
@ -16,30 +16,35 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { defineConfig } from 'vite';
|
||||
import { defineConfig, type LibraryFormats } from 'vite';
|
||||
|
||||
import pkg from './package.json';
|
||||
|
||||
const deps = Object.keys(pkg.dependencies);
|
||||
|
||||
export default defineConfig({
|
||||
export default defineConfig(({ mode }) => ({
|
||||
build: {
|
||||
cssCodeSplit: false,
|
||||
sourcemap: true,
|
||||
minify: false,
|
||||
target: 'esnext',
|
||||
emptyOutDir: false,
|
||||
|
||||
lib: {
|
||||
entry: 'src/index.ts',
|
||||
name: 'TMagicUtils',
|
||||
formats: ['es', 'umd', 'cjs'].includes(mode) ? [mode as LibraryFormats] : ['es', 'umd'],
|
||||
fileName: 'tmagic-utils',
|
||||
},
|
||||
|
||||
rollupOptions: {
|
||||
// 确保外部化处理那些你不想打包进库的依赖
|
||||
external(id: string) {
|
||||
if (mode === 'umd' && id === 'lodash-es') {
|
||||
return false;
|
||||
}
|
||||
return deps.some((k) => new RegExp(`^${k}`).test(id));
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
Loading…
x
Reference in New Issue
Block a user