feat: 建立组件化模板预览基线并规划可视化编辑

This commit is contained in:
que01 committed 2026-10-09 12:32:24 +08:00
1 parent c5af790554
commit 0b14b5a814
46 files changed
+1880 -427

No files matched your search

+25 -7
View File
@@ -4,6 +4,7 @@ import fs from "node:fs";
const root = path.resolve(__dirname, "../../..");
const key = process.env.TEMPLATE_KEY || "acheng-campus-food";
const previewAllTemplates = process.env.PREVIEW_ALL_TEMPLATES === "true";
const templates = fs
.readdirSync(path.join(root, "packages"))
.filter(
@@ -30,20 +31,33 @@ export default defineConfig({
designWidth: 750,
deviceRatio: { 750: 1 },
sourceRoot: "src",
outputRoot: `dist/${key}/${process.env.TARO_ENV || "weapp"}`,
outputRoot: previewAllTemplates
? "dist/template-preview/h5"
: `dist/${key}/${process.env.TARO_ENV || "weapp"}`,
framework: "react",
compiler: { type: "vite" },
plugins: [],
alias: { "@template": path.join(template, "taro") },
alias: {
"@template": previewAllTemplates
? path.resolve(__dirname, "../src/runtime/template-preview-entry.tsx")
: path.join(template, "taro"),
},
defineConstants: {
TEMPLATE_KEY: JSON.stringify(key),
BRAND_SLUG: JSON.stringify(brand),
API_BASE_URL: JSON.stringify(process.env.API_BASE_URL || "http://localhost:3001"),
TEMPLATE_MANIFEST: JSON.stringify(manifest),
PREVIEW_ALL_TEMPLATES: JSON.stringify(previewAllTemplates),
},
copy: {
options: {},
patterns: [
...(previewAllTemplates
? templates.map((templateKey) => ({
from: path.join(root, "packages", `template-${templateKey}`, "miniapp/assets"),
to: `dist/template-preview/h5/assets/${templateKey}`,
}))
: []),
...(process.env.TARO_ENV === "weapp"
? [
{
@@ -52,15 +66,19 @@ export default defineConfig({
},
]
: []),
{
from: path.join(template, "miniapp/assets"),
to: `dist/${key}/${process.env.TARO_ENV || "weapp"}/assets`,
},
...(!previewAllTemplates
? [
{
from: path.join(template, "miniapp/assets"),
to: `dist/${key}/${process.env.TARO_ENV || "weapp"}/assets`,
},
]
: []),
],
},
mini: {},
h5: {
publicPath: "/",
publicPath: process.env.PREVIEW_PUBLIC_PATH || "/",
router: { mode: "hash" },
devServer: { host: "0.0.0.0", port: Number(process.env.PREVIEW_PORT || 3002) },
},