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