diff --git a/package.json b/package.json index 5b3847fd..5c3e8721 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,8 @@ "pg:vue2": "pnpm playground:vue2", "playground:react": "pnpm --filter \"runtime-react\" build:libs && pnpm --filter \"runtime-react\" --filter \"tmagic-playground\" dev:react", "pg:react": "pnpm playground:react", - "build": "pnpm build:dst && pnpm --filter \"@tmagic/*\" build", - "build:dst": "pnpm --filter \"@tmagic/cli\" build && tsc -p tsconfig.build-browser.json && vue-tsc --declaration --emitDeclarationOnly --project tsconfig.build-vue.json && rollup -c rollup.dts.config.js && rimraf temp", + "build": "pnpm build:dts && pnpm --filter \"@tmagic/*\" build", + "build:dts": "pnpm --filter \"@tmagic/cli\" build && tsc -p tsconfig.build-browser.json && vue-tsc --declaration --emitDeclarationOnly --project tsconfig.build-vue.json && rollup -c rollup.dts.config.js && rimraf temp", "check:type": "tsc --incremental --noEmit -p tsconfig.check.json", "build:playground": "pnpm --filter \"runtime-vue3\" build && pnpm --filter \"tmagic-playground\" build", "docs:dev": "vitepress dev docs", diff --git a/packages/core/vite.config.ts b/packages/core/vite.config.ts index 99bb4f0f..9037dc09 100644 --- a/packages/core/vite.config.ts +++ b/packages/core/vite.config.ts @@ -16,23 +16,11 @@ * limitations under the License. */ -import path from 'path'; - import { defineConfig } from 'vite'; import pkg from './package.json'; export default defineConfig({ - resolve: { - alias: - process.env.NODE_ENV === 'production' - ? [] - : [ - { find: /^@tmagic\/schema/, replacement: path.join(__dirname, '../schema/src/index.ts') }, - { find: /^@tmagic\/data-source/, replacement: path.join(__dirname, '../data-source/src/index.ts') }, - ], - }, - build: { cssCodeSplit: false, sourcemap: false, diff --git a/packages/data-source/vite.config.ts b/packages/data-source/vite.config.ts index 10a8fee8..bff470ec 100644 --- a/packages/data-source/vite.config.ts +++ b/packages/data-source/vite.config.ts @@ -24,14 +24,7 @@ import pkg from './package.json'; export default defineConfig(({ mode }) => ({ resolve: { - alias: - process.env.NODE_ENV === 'production' - ? [{ find: /^@data-source/, replacement: path.join(__dirname, './src') }] - : [ - { find: /^@data-source/, replacement: path.join(__dirname, './src') }, - { find: /^@tmagic\/dep/, replacement: path.join(__dirname, '../dep/src/index.ts') }, - { find: /^@tmagic\/schema/, replacement: path.join(__dirname, '../schema/src/index.ts') }, - ], + alias: [{ find: /^@data-source/, replacement: path.join(__dirname, './src') }], }, build: { diff --git a/packages/dep/vite.config.ts b/packages/dep/vite.config.ts index 84e6464d..271ba92a 100644 --- a/packages/dep/vite.config.ts +++ b/packages/dep/vite.config.ts @@ -15,21 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import path from 'path'; - import { defineConfig } from 'vite'; import pkg from './package.json'; export default defineConfig({ - resolve: { - alias: - process.env.NODE_ENV === 'production' - ? [] - : [{ find: /^@tmagic\/schema/, replacement: path.join(__dirname, '../schema/src/index.ts') }], - }, - build: { sourcemap: false, minify: false, diff --git a/packages/design/vite.config.ts b/packages/design/vite.config.ts index f67b608e..333c31bd 100644 --- a/packages/design/vite.config.ts +++ b/packages/design/vite.config.ts @@ -24,14 +24,6 @@ import pkg from './package.json'; export default defineConfig({ plugins: [vue()], - optimizeDeps: { - esbuildOptions: { - define: { - global: 'globalThis', - }, - }, - }, - build: { cssCodeSplit: false, sourcemap: false, diff --git a/packages/editor/vite.config.ts b/packages/editor/vite.config.ts index 356da394..4828d155 100644 --- a/packages/editor/vite.config.ts +++ b/packages/editor/vite.config.ts @@ -27,25 +27,7 @@ export default defineConfig({ plugins: [vue()], resolve: { - alias: - process.env.NODE_ENV === 'production' - ? [{ find: /^@editor/, replacement: path.join(__dirname, './src') }] - : [ - { find: /^@editor/, replacement: path.join(__dirname, './src') }, - { find: /^@tmagic\/schema/, replacement: path.join(__dirname, '../schema/src/index.ts') }, - { find: /^@tmagic\/utils/, replacement: path.join(__dirname, '../utils/src/index.ts') }, - { find: /^@tmagic\/core/, replacement: path.join(__dirname, '../core/src/index.ts') }, - { find: /^@tmagic\/form/, replacement: path.join(__dirname, '../form/src/index.ts') }, - { find: /^@tmagic\/stage/, replacement: path.join(__dirname, '../stage/src/index.ts') }, - ], - }, - - optimizeDeps: { - esbuildOptions: { - define: { - global: 'globalThis', - }, - }, + alias: [{ find: /^@editor/, replacement: path.join(__dirname, './src') }], }, build: { diff --git a/packages/form/vite.config.ts b/packages/form/vite.config.ts index ae87674b..f6c8404d 100644 --- a/packages/form/vite.config.ts +++ b/packages/form/vite.config.ts @@ -16,8 +16,6 @@ * limitations under the License. */ -import path from 'path'; - import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; @@ -26,16 +24,6 @@ import pkg from './package.json'; export default defineConfig({ plugins: [vue()], - resolve: { - alias: - process.env.NODE_ENV === 'production' - ? [] - : [ - { find: /^@tmagic\/utils/, replacement: path.join(__dirname, '../utils/src/index.ts') }, - { find: /^@tmagic\/design/, replacement: path.join(__dirname, '../design/src/index.ts') }, - ], - }, - build: { cssCodeSplit: false, sourcemap: false, diff --git a/packages/stage/vite.config.ts b/packages/stage/vite.config.ts index 545f2e8a..2246afc2 100644 --- a/packages/stage/vite.config.ts +++ b/packages/stage/vite.config.ts @@ -15,25 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import path from 'path'; - import { defineConfig } from 'vite'; import pkg from './package.json'; export default defineConfig({ - resolve: { - alias: - process.env.NODE_ENV === 'production' - ? [] - : [ - { find: /^@tmagic\/core/, replacement: path.join(__dirname, '../core/src/index.ts') }, - { find: /^@tmagic\/schema/, replacement: path.join(__dirname, '../schema/src/index.ts') }, - { find: /^@tmagic\/utils/, replacement: path.join(__dirname, '../utils/src/index.ts') }, - ], - }, - build: { cssCodeSplit: false, sourcemap: false, diff --git a/packages/table/vite.config.ts b/packages/table/vite.config.ts index 7e2e1feb..03207b48 100644 --- a/packages/table/vite.config.ts +++ b/packages/table/vite.config.ts @@ -16,8 +16,6 @@ * limitations under the License. */ -import path from 'path'; - import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; @@ -26,16 +24,6 @@ import pkg from './package.json'; export default defineConfig({ plugins: [vue()], - resolve: { - alias: - process.env.NODE_ENV === 'production' - ? [] - : [ - { find: /^@tmagic\/form/, replacement: path.join(__dirname, '../form/src/index.ts') }, - { find: /^@tmagic\/design/, replacement: path.join(__dirname, '../form/design/index.ts') }, - ], - }, - build: { cssCodeSplit: false, sourcemap: false, diff --git a/packages/ui/package.json b/packages/ui/package.json index c9c51d17..bc21b97b 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -15,6 +15,9 @@ "engines": { "node": ">=18" }, + "scripts": { + "build": "vite build" + }, "license": "Apache-2.0", "repository": { "type": "git", diff --git a/packages/ui/vite.config.ts b/packages/ui/vite.config.ts new file mode 100644 index 00000000..4ae32904 --- /dev/null +++ b/packages/ui/vite.config.ts @@ -0,0 +1,46 @@ +/* + * Tencent is pleased to support the open source community by making TMagicEditor available. + * + * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { defineConfig } from 'vite'; + +import pkg from './package.json'; + +export default defineConfig({ + build: { + cssCodeSplit: false, + sourcemap: false, + minify: false, + target: 'esnext', + + lib: { + entry: 'src/index.ts', + name: 'TMagicUi', + fileName: 'tmagic-ui', + }, + + rollupOptions: { + // 确保外部化处理那些你不想打包进库的依赖 + external(id: string) { + return Object.keys({ + ...pkg.dependencies, + ...pkg.peerDependencies, + }).some((k) => new RegExp(`^${k}`).test(id)); + }, + }, + }, +}); diff --git a/packages/utils/vite.config.ts b/packages/utils/vite.config.ts index 3d5a4b35..c8e3a30f 100644 --- a/packages/utils/vite.config.ts +++ b/packages/utils/vite.config.ts @@ -23,7 +23,7 @@ import pkg from './package.json'; export default defineConfig(({ mode }) => ({ build: { cssCodeSplit: false, - sourcemap: true, + sourcemap: false, minify: false, target: 'esnext', emptyOutDir: false, diff --git a/tsconfig.build-browser.json b/tsconfig.build-browser.json index ce6e4997..ccb59bb6 100644 --- a/tsconfig.build-browser.json +++ b/tsconfig.build-browser.json @@ -13,5 +13,6 @@ "packages/stage/src", "packages/utils/src", "packages/element-plus-adapter/src", + "packages/ui/src", ] }