diff --git a/docs/src/admin/introduction.md b/docs/src/admin/introduction.md index 600f6258..7c29059d 100644 --- a/docs/src/admin/introduction.md +++ b/docs/src/admin/introduction.md @@ -143,11 +143,11 @@ watchEffect(async () => { 在管理端中我们提供了一个可视化的模拟画布,他需要依赖 runtime 核心库,因此我们需要先在 magic 根目录下运行 ```js -cd magic -npm run build +cd tmatic-editor +npm run build:runtime:admin ``` -将 /playground/dist/runtime 文件夹复制到 /magic-admin/web/public 和 /magic-admin/server/assets 目录下。web 下的 runtime 提供给模拟画布使用,server 下的 runtime 提供给发布后的页面来使用。 +将/runtime/{vue3 | vue2 | react}/admin-dist 中所有文件以及文件夹复制到 /magic/runtime 目录下 上面的操作我们提供了/magic-admin/setup.sh 脚本文件来实现,开发者可以参考该脚本文件来搭建流水线。 diff --git a/magic-admin/setup.sh b/magic-admin/setup.sh index 4279ada0..403f138e 100755 --- a/magic-admin/setup.sh +++ b/magic-admin/setup.sh @@ -4,8 +4,8 @@ WORKSPACE=$(dirname "$PWD") echo ${WORKSPACE} -# 全局安装lerna -npm i lerna -g +# 全局安装pnpm +npm i pnpm -g # magic依赖安装和构建 cd ${WORKSPACE} diff --git a/package.json b/package.json index 1e1ef485..b3dfac1b 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "playground:react": "pnpm --filter \"runtime-react\" --filter \"tmagic-playground\" dev:react", "pg:react": "pnpm playground:react", "build": "pnpm --filter \"@tmagic/*\" build", + "build:runtime:admin": "pnpm --filter \"runtime-*\" build:admin", "build:playground": "pnpm --filter \"runtime-*\" --filter \"tmagic-playground\" build", "postbuild:playground": "shx mkdir playground/dist/runtime && shx cp -r runtime/vue2/dist ./playground/dist/runtime/vue2 && shx cp -r runtime/vue3/dist ./playground/dist/runtime/vue3 && cp -r runtime/react/dist ./playground/dist/runtime/react", "docs": "pnpm --filter \"docs\" dev", diff --git a/runtime/react/.env.admin b/runtime/react/.env.admin new file mode 100644 index 00000000..db8e871a --- /dev/null +++ b/runtime/react/.env.admin @@ -0,0 +1,2 @@ +BASE=/runtime +OUT_DIR=admin-dist diff --git a/runtime/react/.gitignore b/runtime/react/.gitignore index 7e7d181f..3ca491ff 100644 --- a/runtime/react/.gitignore +++ b/runtime/react/.gitignore @@ -1,4 +1,5 @@ comp-entry.ts config-entry.ts value-entry.ts -event-entry.ts \ No newline at end of file +event-entry.ts +admin-dist diff --git a/runtime/react/package.json b/runtime/react/package.json index fb1f7a8e..20821886 100644 --- a/runtime/react/package.json +++ b/runtime/react/package.json @@ -5,6 +5,7 @@ "scripts": { "dev:react": "npm run entry && npm run build:lib & npm run dev:html", "build": "npm run entry && vite build", + "build:admin": "npm run entry && vite build --mode admin", "serve": "vite preview", "entry": "node scripts/build.js", "build:lib": "vite build --mode lib", diff --git a/runtime/react/playground.html b/runtime/react/playground.html index 3865d911..ab96e629 100644 --- a/runtime/react/playground.html +++ b/runtime/react/playground.html @@ -22,8 +22,6 @@
- - \ No newline at end of file diff --git a/runtime/react/vite.config.ts b/runtime/react/vite.config.ts index 131c0714..5c50a3a2 100644 --- a/runtime/react/vite.config.ts +++ b/runtime/react/vite.config.ts @@ -22,7 +22,7 @@ import { defineConfig, loadEnv } from 'vite'; import reactRefresh from '@vitejs/plugin-react-refresh'; export default defineConfig(({ command, mode }) => { - const { WATCH_INCLUDE = '' } = loadEnv(mode, process.cwd(), ''); + const { WATCH_INCLUDE = '', BASE, OUT_DIR } = loadEnv(mode, process.cwd(), ''); const libInput = { config: './src/config-entry.ts', value: './src/value-entry.ts', @@ -37,6 +37,8 @@ export default defineConfig(({ command, mode }) => { const devInput = mode === 'lib' ? libInput : htmlInput; const buildConfig = { + outDir: OUT_DIR || 'dist', + sourcemap: true, cssCodeSplit: false, @@ -67,7 +69,7 @@ export default defineConfig(({ command, mode }) => { } return { - base: '/tmagic-editor/playground/runtime/react', + base: BASE || '/tmagic-editor/playground/runtime/react', plugins: [reactRefresh()], diff --git a/runtime/vue2/.env.admin b/runtime/vue2/.env.admin new file mode 100644 index 00000000..db8e871a --- /dev/null +++ b/runtime/vue2/.env.admin @@ -0,0 +1,2 @@ +BASE=/runtime +OUT_DIR=admin-dist diff --git a/runtime/vue2/.gitignore b/runtime/vue2/.gitignore index 7e7d181f..3ca491ff 100644 --- a/runtime/vue2/.gitignore +++ b/runtime/vue2/.gitignore @@ -1,4 +1,5 @@ comp-entry.ts config-entry.ts value-entry.ts -event-entry.ts \ No newline at end of file +event-entry.ts +admin-dist diff --git a/runtime/vue2/package.json b/runtime/vue2/package.json index ff98177d..3a1d54d7 100644 --- a/runtime/vue2/package.json +++ b/runtime/vue2/package.json @@ -5,6 +5,7 @@ "scripts": { "dev:vue2": "npm run entry && npm run build:lib & npm run dev:html", "build": "npm run entry && vite build", + "build:admin": "npm run entry && vite build --mode admin", "serve": "vite preview", "entry": "node scripts/build.js", "build:lib": "vite build --mode lib", diff --git a/runtime/vue2/page.html b/runtime/vue2/page.html index 2fa5313a..d7bb827a 100644 --- a/runtime/vue2/page.html +++ b/runtime/vue2/page.html @@ -4,7 +4,7 @@ Vue2 Page - +
diff --git a/runtime/vue2/playground.html b/runtime/vue2/playground.html index 5e0ba84e..118cada7 100644 --- a/runtime/vue2/playground.html +++ b/runtime/vue2/playground.html @@ -22,7 +22,6 @@
- diff --git a/runtime/vue2/vite.config.ts b/runtime/vue2/vite.config.ts index d53e3b30..b700f77e 100644 --- a/runtime/vue2/vite.config.ts +++ b/runtime/vue2/vite.config.ts @@ -24,7 +24,7 @@ import vue from '@vitejs/plugin-vue2'; import externalGlobals from 'rollup-plugin-external-globals'; export default defineConfig(({ command, mode }) => { - const { WATCH_INCLUDE = '' } = loadEnv(mode, process.cwd(), ''); + const { WATCH_INCLUDE = '', BASE, OUT_DIR } = loadEnv(mode, process.cwd(), ''); const libInput = { config: './src/config-entry.ts', value: './src/value-entry.ts', @@ -39,6 +39,8 @@ export default defineConfig(({ command, mode }) => { const devInput = mode === 'lib' ? libInput : htmlInput; const buildConfig = { + outDir: OUT_DIR || 'dist', + sourcemap: true, cssCodeSplit: false, @@ -69,7 +71,7 @@ export default defineConfig(({ command, mode }) => { } return { - base: '/tmagic-editor/playground/runtime/vue2', + base: BASE || '/tmagic-editor/playground/runtime/vue2', plugins: [vue(), externalGlobals({ vue: 'Vue' }, { exclude: ['page.html', 'playground.html'] })], diff --git a/runtime/vue3/.env.admin b/runtime/vue3/.env.admin new file mode 100644 index 00000000..db8e871a --- /dev/null +++ b/runtime/vue3/.env.admin @@ -0,0 +1,2 @@ +BASE=/runtime +OUT_DIR=admin-dist diff --git a/runtime/vue3/.gitignore b/runtime/vue3/.gitignore index 7e7d181f..3ca491ff 100644 --- a/runtime/vue3/.gitignore +++ b/runtime/vue3/.gitignore @@ -1,4 +1,5 @@ comp-entry.ts config-entry.ts value-entry.ts -event-entry.ts \ No newline at end of file +event-entry.ts +admin-dist diff --git a/runtime/vue3/package.json b/runtime/vue3/package.json index 97d7c910..9c3b9e52 100644 --- a/runtime/vue3/package.json +++ b/runtime/vue3/package.json @@ -5,6 +5,7 @@ "scripts": { "dev": "npm run entry && npm run build:lib & npm run dev:html", "build": "npm run entry && vite build", + "build:admin": "npm run entry && vite build --mode admin", "serve": "vite preview", "entry": "node scripts/build.js", "build:lib": "vite build --mode lib", diff --git a/runtime/vue3/playground.html b/runtime/vue3/playground.html index 7287a952..f611b449 100644 --- a/runtime/vue3/playground.html +++ b/runtime/vue3/playground.html @@ -22,7 +22,6 @@
- diff --git a/runtime/vue3/vite.config.ts b/runtime/vue3/vite.config.ts index 5e02f2de..9e81b6c7 100644 --- a/runtime/vue3/vite.config.ts +++ b/runtime/vue3/vite.config.ts @@ -26,7 +26,7 @@ import vueJsx from '@vitejs/plugin-vue-jsx'; import externalGlobals from 'rollup-plugin-external-globals'; export default defineConfig(({ command, mode }) => { - const { WATCH_INCLUDE = '' } = loadEnv(mode, process.cwd(), ''); + const { WATCH_INCLUDE = '', BASE, OUT_DIR } = loadEnv(mode, process.cwd(), ''); const libInput = { config: './src/config-entry.ts', value: './src/value-entry.ts', @@ -41,6 +41,8 @@ export default defineConfig(({ command, mode }) => { const devInput = mode === 'lib' ? libInput : htmlInput; const buildConfig = { + outDir: OUT_DIR || 'dist', + sourcemap: true, cssCodeSplit: false, @@ -71,7 +73,7 @@ export default defineConfig(({ command, mode }) => { } return { - base: '/tmagic-editor/playground/runtime/vue3', + base: BASE || '/tmagic-editor/playground/runtime/vue3', plugins: [vue(), vueJsx(), externalGlobals({ vue: 'Vue' }, { exclude: ['page.html', 'playground.html'] })],