create-weapp-vite 2.7.3 → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +14 -1
  2. package/dist/cli.js +9 -1
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.js +1 -1
  5. package/dist/{src-oq4dsVyY.js → src-DLBjE7f9.js} +45 -27
  6. package/package.json +4 -4
  7. package/templates/multi-platform/.editorconfig +9 -0
  8. package/templates/multi-platform/README.md +46 -0
  9. package/templates/multi-platform/config/alipay/mini.project.json +8 -0
  10. package/templates/multi-platform/config/jd/project.config.json +4 -0
  11. package/templates/multi-platform/config/swan/project.swan.json +8 -0
  12. package/templates/multi-platform/config/tt/project.config.json +10 -0
  13. package/templates/multi-platform/config/weapp/project.config.json +24 -0
  14. package/templates/multi-platform/config/xhs/project.config.json +10 -0
  15. package/templates/multi-platform/eslint.config.js +6 -0
  16. package/templates/multi-platform/gitignore +30 -0
  17. package/templates/multi-platform/index.html +13 -0
  18. package/templates/multi-platform/package.json +47 -0
  19. package/templates/multi-platform/src/app.json +13 -0
  20. package/templates/multi-platform/src/app.scss +5 -0
  21. package/templates/multi-platform/src/app.ts +3 -0
  22. package/templates/multi-platform/src/components/PlatformCard/index.json +5 -0
  23. package/templates/multi-platform/src/components/PlatformCard/index.scss +25 -0
  24. package/templates/multi-platform/src/components/PlatformCard/index.ts +8 -0
  25. package/templates/multi-platform/src/components/PlatformCard/index.wxml +5 -0
  26. package/templates/multi-platform/src/pages/index/index.json +7 -0
  27. package/templates/multi-platform/src/pages/index/index.scss +72 -0
  28. package/templates/multi-platform/src/pages/index/index.ts +12 -0
  29. package/templates/multi-platform/src/pages/index/index.wxml +22 -0
  30. package/templates/multi-platform/src/pages/index/platform.wxs +7 -0
  31. package/templates/multi-platform/src/sitemap.json +9 -0
  32. package/templates/multi-platform/stylelint.config.js +5 -0
  33. package/templates/multi-platform/tsconfig.json +17 -0
  34. package/templates/multi-platform/vite.config.ts +43 -0
  35. package/templates/multi-platform-sfc/.editorconfig +9 -0
  36. package/templates/multi-platform-sfc/README.md +43 -0
  37. package/templates/multi-platform-sfc/config/alipay/mini.project.json +8 -0
  38. package/templates/multi-platform-sfc/config/jd/project.config.json +4 -0
  39. package/templates/multi-platform-sfc/config/swan/project.swan.json +8 -0
  40. package/templates/multi-platform-sfc/config/tt/project.config.json +10 -0
  41. package/templates/multi-platform-sfc/config/weapp/project.config.json +24 -0
  42. package/templates/multi-platform-sfc/config/xhs/project.config.json +10 -0
  43. package/templates/multi-platform-sfc/eslint.config.js +7 -0
  44. package/templates/multi-platform-sfc/gitignore +30 -0
  45. package/templates/multi-platform-sfc/index.html +13 -0
  46. package/templates/multi-platform-sfc/package.json +48 -0
  47. package/templates/multi-platform-sfc/src/app.vue +19 -0
  48. package/templates/multi-platform-sfc/src/components/PlatformCard/index.vue +55 -0
  49. package/templates/multi-platform-sfc/src/pages/index/index.vue +134 -0
  50. package/templates/multi-platform-sfc/src/sitemap.json +9 -0
  51. package/templates/multi-platform-sfc/stylelint.config.js +5 -0
  52. package/templates/multi-platform-sfc/tsconfig.json +17 -0
  53. package/templates/multi-platform-sfc/vite.config.ts +26 -0
  54. package/templates/react/package.json +1 -1
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  ## 特性
8
8
 
9
9
  - 交互式创建或非交互式参数创建
10
- - 内置多种模板(默认、Wevu、Wevu + TDesign、Tailwindcss、TDesign、Vant、插件、组件库)
10
+ - 内置多种模板(默认、原生多平台 + Web、Vue SFC 多平台 + Web、Wevu、Wevu + TDesign、Tailwindcss、TDesign、Vant、插件、组件库)
11
11
  - 自动对齐 `weapp-vite` 与 `wevu` 版本
12
12
  - 自动处理 `.gitignore` 写入
13
13
  - 可选安装推荐的 AI skills(`sonofmagic/skills`)
@@ -45,6 +45,12 @@ npx skills add sonofmagic/skills
45
45
  ```bash
46
46
  pnpm create weapp-vite my-app wevu
47
47
 
48
+ # 原生多平台 + Web 模板
49
+ pnpm create weapp-vite my-app multi-platform
50
+
51
+ # Vue SFC 多平台 + Web 模板
52
+ pnpm create weapp-vite my-app multi-platform-sfc
53
+
48
54
  # 显式安装推荐 skills
49
55
  pnpm create weapp-vite my-app wevu --install-skills
50
56
 
@@ -66,7 +72,10 @@ await createProject('my-app', TemplateName.wevu, { installSkills: true })
66
72
  `TemplateName` 支持以下模板:
67
73
 
68
74
  - `default`
75
+ - `multi-platform`
76
+ - `multi-platform-sfc`
69
77
  - `wevu`
78
+ - `react`
70
79
  - `wevu-tdesign`
71
80
  - `tailwindcss`
72
81
  - `tdesign`
@@ -74,6 +83,10 @@ await createProject('my-app', TemplateName.wevu, { installSkills: true })
74
83
  - `plugin`
75
84
  - `lib`
76
85
 
86
+ `multi-platform` 使用原生 Page/Component,覆盖微信、支付宝、抖音、百度、京东、小红书与 Web Runtime。它按命令构建单个目标,不会隐式生成全部平台产物;创建后请使用 `dev:<platform>` / `build:<platform>` 脚本。
87
+
88
+ `multi-platform-sfc` 使用 Wevu + Vue SFC 覆盖相同目标,并提供 `defineAppJson` / `definePageJson` / `defineComponentJson`、受管类型文件和稳定响应式交互示例。Web Runtime 用于浏览器联调,不能替代目标小程序 IDE 或真机验收。
89
+
77
90
  ## 相关链接
78
91
 
79
92
  - weapp-vite 文档:https://vite.icebreaker.top/
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as RECOMMENDED_SKILLS_INSTALL_COMMAND, t as createProject } from "./src-oq4dsVyY.js";
1
+ import { n as RECOMMENDED_SKILLS_INSTALL_COMMAND, t as createProject } from "./src-DLBjE7f9.js";
2
2
  import logger from "@weapp-core/logger";
3
3
  import { fs } from "@weapp-core/shared/fs";
4
4
  import process from "node:process";
@@ -12,6 +12,14 @@ const TEMPLATE_CHOICES = [
12
12
  name: "默认模板",
13
13
  value: "default"
14
14
  },
15
+ {
16
+ name: "原生多平台 + Web 模板",
17
+ value: "multi-platform"
18
+ },
19
+ {
20
+ name: "Vue SFC 多平台 + Web 模板",
21
+ value: "multi-platform-sfc"
22
+ },
15
23
  {
16
24
  name: "Wevu 模板 (Vue SFC)",
17
25
  value: "wevu"
package/dist/index.d.ts CHANGED
@@ -2,6 +2,8 @@ import "pkg-types";
2
2
  //#region src/enums.d.ts
3
3
  declare enum TemplateName {
4
4
  default = "default",
5
+ multiPlatform = "multi-platform",
6
+ multiPlatformSfc = "multi-platform-sfc",
5
7
  plugin = "plugin",
6
8
  wevu = "wevu",
7
9
  tailwindcss = "tailwindcss",
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { r as TemplateName, t as createProject } from "./src-oq4dsVyY.js";
1
+ import { r as TemplateName, t as createProject } from "./src-DLBjE7f9.js";
2
2
  export { TemplateName, createProject };
@@ -9,17 +9,19 @@ import process from "node:process";
9
9
  var version$3 = "0.2.0";
10
10
  //#endregion
11
11
  //#region ../../packages-runtime/wevu/package.json
12
- var version$2 = "6.20.3";
12
+ var version$2 = "6.20.5";
13
13
  //#endregion
14
14
  //#region ../dashboard/package.json
15
- var version$1 = "6.20.3";
15
+ var version$1 = "6.20.5";
16
16
  //#endregion
17
17
  //#region ../weapp-vite/package.json
18
- var version = "6.20.3";
18
+ var version = "6.20.5";
19
19
  //#endregion
20
20
  //#region src/enums.ts
21
21
  let TemplateName = /* @__PURE__ */ function(TemplateName) {
22
22
  TemplateName["default"] = "default";
23
+ TemplateName["multiPlatform"] = "multi-platform";
24
+ TemplateName["multiPlatformSfc"] = "multi-platform-sfc";
23
25
  TemplateName["plugin"] = "plugin";
24
26
  TemplateName["wevu"] = "wevu";
25
27
  TemplateName["tailwindcss"] = "tailwindcss";
@@ -33,14 +35,24 @@ let TemplateName = /* @__PURE__ */ function(TemplateName) {
33
35
  //#endregion
34
36
  //#region src/agents.ts
35
37
  function supportsWevu(templateName) {
36
- return ["wevu", "wevu-tdesign"].includes(templateName);
38
+ return [
39
+ "wevu",
40
+ "wevu-tdesign",
41
+ "multi-platform-sfc"
42
+ ].includes(templateName);
43
+ }
44
+ function supportsReact(templateName) {
45
+ return templateName === "react";
37
46
  }
38
47
  function supportsNativePages(templateName) {
39
- return !supportsWevu(templateName);
48
+ return !supportsWevu(templateName) && !supportsReact(templateName);
40
49
  }
41
50
  function supportsPlugin(templateName) {
42
51
  return templateName === "plugin";
43
52
  }
53
+ function supportsMultiPlatform(templateName) {
54
+ return ["multi-platform", "multi-platform-sfc"].includes(templateName);
55
+ }
44
56
  /**
45
57
  * @description 生成新项目的 AGENTS 指引
46
58
  */
@@ -95,13 +107,15 @@ function createAgentsGuidelines(templateName) {
95
107
  "- In Codex/Claude environments, prefer these skills first when available:",
96
108
  " - `$weapp-vite-best-practices` for config, build, subpackage, route, DevTools CLI orchestration, and screenshot/compare command work.",
97
109
  " - `$weapp-vite-vue-sfc-best-practices` for `.vue` SFC macros, JSON blocks, and template compatibility.",
98
- " - `$release-and-changeset-best-practices` for issue delivery, changesets, release decisions, and PR workflow.",
110
+ " - `$release-and-changeset-best-practices` for issue delivery, pnpm change intents, repoctl release decisions, and PR workflow.",
99
111
  " - `$docs-and-website-sync` when documentation or AI guidance must be refreshed together with code changes.",
100
112
  " - Use `$weapp-vite-best-practices` for stateful HMR, pluginRoot/dist-plugin, Web runtime compatibility, and native AST profiling; use `$wevu-best-practices` for `wevu/router` navigation semantics.",
101
113
  " - Use `$weapp-devtools-e2e-best-practices` for serialized DevTools runtime suites, shared automator sessions, and known host compatibility skips."
102
114
  ];
103
115
  if (supportsWevu(templateName)) lines.push(" - `$wevu-best-practices` for `wevu` runtime lifecycle, state, store, and event contracts.", "", "## Wevu Authoring", "", "- Import runtime APIs from `wevu` in business code.", "- Register lifecycle hooks synchronously in `setup()` and avoid hook registration after `await`.", "- Prefer `ref`, `reactive`, `computed`, and explicit event contracts over large opaque state writes.", "- Use `storeToRefs` when destructuring store state/getters.", "- Treat mini-program runtime constraints as primary; do not assume Vue web-only behavior.");
116
+ if (supportsReact(templateName)) lines.push(" - `$weapp-vite-react-best-practices` for React 19 JSX/TSX ownership, render modes, root lifecycle, React Compiler, and native/Wevu component bridges.", "", "## React Mini-program Authoring", "", "- Keep `weapp.react` as the project-level owner for all `.jsx` and `.tsx` modules; do not mix Wevu JSX in the same build.", "- Use React 19.2.x, `react-reconciler` 0.33.x, and `@weapp-vite/react` without `react-dom`.", "- Start with `renderMode: 'auto'`; use `dynamic` only for reconciler-tree diagnostics and `static` for strict static-shape validation.", "- Create and unmount `createReactMiniProgramRoot` in the native page/component lifecycle, and forward host events through the root.", "- Register native or Wevu custom components in `usingComponents` before declaring a top-level `createNativeComponent()` bridge in the current TSX file.", "- Treat the current React runtime as WeChat-only; Web, Alipay, and Douyin builds are not runtime compatibility evidence.");
104
117
  if (supportsNativePages(templateName)) lines.push(" - `$native-to-weapp-vite-wevu-migration` when migrating native mini-program projects to `weapp-vite + native`, or further toward Vue SFC / wevu.", "", "## Native Mini-program Authoring", "", "- Keep native page/component structure consistent with the template unless there is a clear migration goal.", "- Prefer `weapp-vite generate` or `wv generate` for new app/page/component scaffolds.", "- If migrating this project, first decide whether the target is `weapp-vite + native` or a further Vue SFC / `wevu` migration, then keep each migration wave explicit.");
118
+ if (supportsMultiPlatform(templateName)) lines.push("", "## Multi-platform Workflow", "", "- This project builds one target at a time. Always pass an explicit platform or use `pnpm dev:<platform>` / `pnpm build:<platform>`.", "- Keep platform IDE configuration under `config/<platform>` and import `dist/<platform>` into the matching mini-program IDE.", "- Use `pnpm dev:web` for browser compatibility work, but keep mini-program DevTools or device acceptance as the release authority.", "- Treat WeChat, Web, official IDE compilation, and unsupported automator targets as separate verification layers; do not report a build-only check as runtime E2E.");
105
119
  if (supportsPlugin(templateName)) lines.push("", "## Plugin Authoring", "", "- Keep `src/` as the host app source and `plugin/` as the plugin source root declared by `weapp.pluginRoot`.", "- Validate both `dist/` and `dist-plugin/` outputs after structural changes to host pages, plugin pages, or plugin public components.", "- If you change plugin AppID or switch away from local `dev` linkage, update both `project.config.json.appid` and `src/app.json` -> `plugins.*.provider` together.", "- Treat shared modules under `shared/` as regular source code that can be imported by both host and plugin entries.");
106
120
  return `${lines.join("\n")}\n`;
107
121
  }
@@ -115,8 +129,8 @@ const TEMPLATE_CATALOG = {
115
129
  "@babel/types": "^8.0.4",
116
130
  "@douyin-microapp/typings": "^1.3.1",
117
131
  "@egoist/tailwindcss-icons": "^1.9.2",
118
- "@icebreakers/eslint-config": "^7.0.2",
119
- "@icebreakers/stylelint-config": "^5.0.3",
132
+ "@icebreakers/eslint-config": "^7.0.4",
133
+ "@icebreakers/stylelint-config": "^5.0.5",
120
134
  "@iconify-json/mdi": "^1.2.3",
121
135
  "@iconify/tailwind4": "^1.2.3",
122
136
  "@mini-types/alipay": "^3.0.14",
@@ -128,7 +142,7 @@ const TEMPLATE_CATALOG = {
128
142
  "@vue/babel-plugin-jsx": "3.0.0",
129
143
  "@vue/compiler-core": "^3.5.41",
130
144
  "@vue/compiler-dom": "^3.5.41",
131
- "@vue/language-core": "^3.3.9",
145
+ "@vue/language-core": "^3.3.10",
132
146
  "@wot-ui/ui": "2.3.2",
133
147
  "antd-mini": "^3.4.3",
134
148
  "bundle-require": "^5.1.0",
@@ -136,25 +150,25 @@ const TEMPLATE_CATALOG = {
136
150
  "comment-json": "^5.0.0",
137
151
  "estree-walker": "^3.0.3",
138
152
  "gm-crypto": "^0.1.12",
139
- "happy-dom": "^20.11.2",
153
+ "happy-dom": "^20.11.6",
140
154
  "lru-cache": "^11.5.2",
141
- "magic-string": "^1.2.0",
155
+ "magic-string": "^1.2.2",
142
156
  "miniprogram-api-typings": "^5.2.3",
143
- "oxc-parser": "^0.144.0",
157
+ "oxc-parser": "^0.146.0",
144
158
  "oxc-walker": "^1.1.1",
145
159
  "pkg-types": "^2.3.1",
146
- "sass-embedded": "^1.102.0",
160
+ "sass-embedded": "^1.103.1",
147
161
  "tailwind-merge": "^3.6.0",
148
162
  "tailwind-variants": "^3.3.1",
149
163
  "tdesign-miniprogram": "^1.16.0",
150
164
  "ts-morph": "^28.0.0",
151
- "uview-plus": "3.8.86",
165
+ "uview-plus": "3.8.108",
152
166
  "vite-plugin-inspect": "^12.0.2",
153
- "vue-tsc": "^3.3.9",
154
- "weapp-tailwindcss": "^5.2.14",
167
+ "vue-tsc": "^3.3.10",
168
+ "weapp-tailwindcss": "^5.3.3",
155
169
  autoprefixer: "^10.5.4",
156
170
  clsx: "^2.1.1",
157
- dayjs: "^1.11.21",
171
+ dayjs: "^1.11.23",
158
172
  echarts: "^6.1.0",
159
173
  esbuild: "^0.28.2",
160
174
  eslint: "^10.8.1",
@@ -165,20 +179,20 @@ const TEMPLATE_CATALOG = {
165
179
  obug: "^2.1.4",
166
180
  pathe: "^2.0.3",
167
181
  postcss: "^8.5.26",
168
- rolldown: "1.2.4",
169
- sass: "^1.102.0",
182
+ rolldown: "1.2.5",
183
+ sass: "^1.103.1",
170
184
  stylelint: "^17.14.1",
171
185
  tailwindcss: "^4.3.3",
172
186
  tslib: "^2.8.1",
173
187
  tsx: "^4.23.12",
174
188
  typescript: "^6.0.3",
175
- vite: "8.2.1",
189
+ vite: "8.2.2",
176
190
  vue: "^3.5.41",
177
191
  zod: "^4.4.3"
178
192
  };
179
193
  const TEMPLATE_NAMED_CATALOG = {
180
194
  "tdesign-miniprogram-fixed": { "tdesign-miniprogram": "1.16.0" },
181
- "weapp-tailwindcss-fixed": { "weapp-tailwindcss": "5.2.14" },
195
+ "weapp-tailwindcss-fixed": { "weapp-tailwindcss": "5.3.3" },
182
196
  latest: {
183
197
  "miniprogram-api-typings": "^5.2.3",
184
198
  typescript: "^6.0.3"
@@ -406,6 +420,8 @@ const TOURIST_APP_ID = "touristappid";
406
420
  const moduleDir = path.dirname(fileURLToPath(import.meta.url));
407
421
  const TEMPLATE_DIR_MAP = {
408
422
  ["default"]: "weapp-vite-template",
423
+ ["multi-platform"]: "weapp-vite-multi-platform-template",
424
+ ["multi-platform-sfc"]: "weapp-vite-multi-platform-sfc-template",
409
425
  ["plugin"]: "weapp-vite-plugin-template",
410
426
  ["lib"]: "weapp-vite-lib-template",
411
427
  ["wevu"]: "weapp-vite-wevu-template",
@@ -485,12 +501,14 @@ async function ensureDotGitignore(root) {
485
501
  await fs.move(gitignorePath, dotGitignorePath);
486
502
  }
487
503
  async function rewriteProjectConfigAppId(targetDir) {
488
- const projectConfigPath = path.resolve(targetDir, "project.config.json");
489
- if (!await fs.pathExists(projectConfigPath)) return;
490
- const projectConfig = await fs.readJSON(projectConfigPath);
491
- if (!projectConfig || typeof projectConfig !== "object" || projectConfig.compileType === "plugin" || projectConfig.appid === TOURIST_APP_ID) return;
492
- projectConfig.appid = TOURIST_APP_ID;
493
- await writeJsonFile(projectConfigPath, projectConfig);
504
+ const projectConfigPaths = [path.resolve(targetDir, "project.config.json"), path.resolve(targetDir, "config/weapp/project.config.json")];
505
+ for (const projectConfigPath of projectConfigPaths) {
506
+ if (!await fs.pathExists(projectConfigPath)) continue;
507
+ const projectConfig = await fs.readJSON(projectConfigPath);
508
+ if (!projectConfig || typeof projectConfig !== "object" || projectConfig.compileType === "plugin" || projectConfig.appid === TOURIST_APP_ID) continue;
509
+ projectConfig.appid = TOURIST_APP_ID;
510
+ await writeJsonFile(projectConfigPath, projectConfig);
511
+ }
494
512
  }
495
513
  function createEmptyPackageJson() {
496
514
  return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-weapp-vite",
3
3
  "type": "module",
4
- "version": "2.7.3",
4
+ "version": "2.8.1",
5
5
  "description": "create-weapp-vite",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -46,12 +46,12 @@
46
46
  "node": "^20.19.0 || >=22.12.0"
47
47
  },
48
48
  "dependencies": {
49
- "@inquirer/prompts": "^8.5.2",
49
+ "@inquirer/prompts": "^8.6.0",
50
50
  "pathe": "^2.0.3",
51
51
  "pkg-types": "^2.3.1",
52
52
  "@weapp-core/init": "6.0.14",
53
- "@weapp-core/logger": "3.1.1",
54
- "@weapp-core/shared": "3.1.1"
53
+ "@weapp-core/shared": "3.1.1",
54
+ "@weapp-core/logger": "3.1.1"
55
55
  },
56
56
  "scripts": {
57
57
  "catalog:sync": "node --import tsx scripts/generate-template-catalog.ts",
@@ -0,0 +1,9 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
@@ -0,0 +1,46 @@
1
+ # weapp-vite 原生多平台 + Web 模板
2
+
3
+ 这个模板使用同一份原生小程序源码,按命令选择单个目标平台构建。当前覆盖微信、支付宝、抖音、百度、京东、小红书和 Web Runtime。
4
+
5
+ ```sh
6
+ pnpm create weapp-vite my-app multi-platform
7
+ cd my-app
8
+ pnpm install
9
+ pnpm dev:weapp
10
+ ```
11
+
12
+ ## 开发
13
+
14
+ ```sh
15
+ pnpm dev:weapp
16
+ pnpm dev:alipay
17
+ pnpm dev:tt
18
+ pnpm dev:swan
19
+ pnpm dev:jd
20
+ pnpm dev:xhs
21
+ pnpm dev:web
22
+ ```
23
+
24
+ `pnpm dev` 默认等价于 `pnpm dev:weapp`。需要打开开发者工具时使用 `pnpm dev:open`、`pnpm open:weapp` 或 `pnpm open:alipay`。
25
+
26
+ ## 构建
27
+
28
+ ```sh
29
+ pnpm build:weapp
30
+ pnpm build:alipay
31
+ pnpm build:tt
32
+ pnpm build:swan
33
+ pnpm build:jd
34
+ pnpm build:xhs
35
+ pnpm build:web
36
+ ```
37
+
38
+ 每条命令只构建一个目标。小程序产物位于 `dist/<platform>/dist`,对应的 IDE 项目位于 `dist/<platform>`;Web 产物位于 `dist/web`。
39
+
40
+ ## 平台配置
41
+
42
+ 各平台项目配置位于 `config/<platform>`。创建项目后请先替换目标平台的 AppID,再导入对应的 `dist/<platform>` 目录。
43
+
44
+ 便携源码使用原生 `Page()` / `Component()`,公共模板采用 WXML 语法,并通过 `wx` API 编写平台无关逻辑。构建时 `injectWeapi.replaceWx` 会替换运行时 API,模板、样式、事件和脚本模块后缀会按目标平台转换。平台专属能力应隔离在独立模块或条件入口中,避免让公共页面直接依赖某个宿主的 TypeScript 类型。
45
+
46
+ Web Runtime 适合浏览器联调和兼容验证,不能替代小程序开发者工具或真机验收。构建通过也不等于官方 IDE 编译或 Runtime 交互通过:微信和 Web 可以做自动化交互验收,支付宝使用官方 `minidev build` 做 IDE 编译检查,百度 Runtime 依赖可用的 WebSocket 端点,抖音、京东和小红书仍需在各自官方工具中人工复验。详细说明见 [多平台构建指南](https://vite.icebreaker.top/guide/multi-platform)。
@@ -0,0 +1,8 @@
1
+ {
2
+ "format": 2,
3
+ "compileType": "mini",
4
+ "miniprogramRoot": "dist",
5
+ "compileOptions": {
6
+ "typescript": false
7
+ }
8
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "appid": "your_appid",
3
+ "miniprogramRoot": "dist"
4
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "smartProgramRoot": "dist",
3
+ "appid": "your_appid",
4
+ "compileType": "miniprogram",
5
+ "setting": {
6
+ "urlCheck": false
7
+ }
8
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "appid": "your_appid",
3
+ "projectname": "weapp-vite-multi-platform-template",
4
+ "miniprogramRoot": "dist",
5
+ "setting": {
6
+ "es6": true,
7
+ "urlCheck": false,
8
+ "compileHotReLoad": false
9
+ }
10
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "description": "weapp-vite 多平台模板",
3
+ "miniprogramRoot": "dist",
4
+ "srcMiniprogramRoot": "dist",
5
+ "compileType": "miniprogram",
6
+ "setting": {
7
+ "urlCheck": false,
8
+ "babelSetting": {
9
+ "ignore": [],
10
+ "disablePlugins": [],
11
+ "outputPath": ""
12
+ },
13
+ "postcss": false,
14
+ "minified": false,
15
+ "ignoreUploadUnusedFiles": true,
16
+ "compileHotReLoad": false,
17
+ "packNpmManually": true,
18
+ "es6": true
19
+ },
20
+ "simulatorType": "wechat",
21
+ "libVersion": "3.13.2",
22
+ "condition": {},
23
+ "appid": "wxb3d842a4a7e3440d"
24
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "description": "weapp-vite 多平台模板",
3
+ "miniprogramRoot": "dist",
4
+ "compileType": "miniprogram",
5
+ "setting": {
6
+ "es6": true,
7
+ "compileHotReload": false
8
+ },
9
+ "appid": "your_appid"
10
+ }
@@ -0,0 +1,6 @@
1
+ import { icebreaker } from '@icebreakers/eslint-config'
2
+
3
+ export default icebreaker({
4
+ miniProgram: true,
5
+ ignores: ['CHANGELOG.md', 'README.md', '.turbo/**', 'dist/**', '.weapp-vite/**'],
6
+ })
@@ -0,0 +1,30 @@
1
+ # dependencies
2
+ node_modules
3
+ .pnp
4
+ .pnp.js
5
+
6
+ # testing
7
+ coverage
8
+
9
+ # misc
10
+ .DS_Store
11
+ *.pem
12
+
13
+ # debug
14
+ npm-debug.log*
15
+ yarn-debug.log*
16
+ yarn-error.log*
17
+ .pnpm-debug.log*
18
+
19
+ # local env files
20
+ .env.local
21
+ .env.development.local
22
+ .env.test.local
23
+ .env.production.local
24
+
25
+ # turbo
26
+ .turbo
27
+
28
+ dist
29
+ vite.config.ts.timestamp-*.mjs
30
+ .weapp-vite/
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <link rel="icon" href="data:," />
7
+ <title>weapp-vite 多平台模板</title>
8
+ </head>
9
+ <body>
10
+ <div id="app"></div>
11
+ <script type="module" src="/@weapp-vite/web/entry"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "weapp-vite-multi-platform-template",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "private": true,
6
+ "description": "weapp-vite 原生多平台与 Web 模板",
7
+ "license": "MIT",
8
+ "scripts": {
9
+ "dev": "wv dev -p weapp",
10
+ "dev:weapp": "wv dev -p weapp",
11
+ "dev:alipay": "wv dev -p alipay",
12
+ "dev:tt": "wv dev -p tt",
13
+ "dev:swan": "wv dev -p swan",
14
+ "dev:jd": "wv dev -p jd",
15
+ "dev:xhs": "wv dev -p xhs",
16
+ "dev:web": "wv dev -p web --host",
17
+ "dev:open": "wv dev -p weapp -o",
18
+ "build": "wv build -p weapp",
19
+ "build:weapp": "wv build -p weapp",
20
+ "build:alipay": "wv build -p alipay",
21
+ "build:tt": "wv build -p tt",
22
+ "build:swan": "wv build -p swan",
23
+ "build:jd": "wv build -p jd",
24
+ "build:xhs": "wv build -p xhs",
25
+ "build:web": "wv build -p web",
26
+ "open:weapp": "wv open -p weapp",
27
+ "open:alipay": "wv open -p alipay",
28
+ "lint": "eslint .",
29
+ "lint:fix": "eslint . --fix",
30
+ "stylelint": "stylelint \"src/**/*.{css,scss,vue,wxss}\" --allow-empty-input",
31
+ "stylelint:fix": "stylelint \"src/**/*.{css,scss,vue,wxss}\" --fix --allow-empty-input",
32
+ "g": "wv generate",
33
+ "postinstall": "wv prepare -p weapp"
34
+ },
35
+ "devDependencies": {
36
+ "@icebreakers/eslint-config": "catalog:",
37
+ "@icebreakers/stylelint-config": "catalog:",
38
+ "@types/node": "catalog:",
39
+ "@weapp-vite/dashboard": "workspace:*",
40
+ "eslint": "catalog:",
41
+ "miniprogram-api-typings": "catalog:",
42
+ "sass": "catalog:",
43
+ "stylelint": "catalog:",
44
+ "typescript": "catalog:",
45
+ "weapp-vite": "workspace:*"
46
+ }
47
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/app.json",
3
+ "pages": [
4
+ "pages/index/index"
5
+ ],
6
+ "window": {
7
+ "navigationBarTitleText": "多平台模板",
8
+ "navigationBarBackgroundColor": "#ffffff",
9
+ "navigationBarTextStyle": "black",
10
+ "backgroundColor": "#f4f6f8"
11
+ },
12
+ "sitemapLocation": "sitemap.json"
13
+ }
@@ -0,0 +1,5 @@
1
+ page {
2
+ min-height: 100%;
3
+ color: #17212b;
4
+ background: #f4f6f8;
5
+ }
@@ -0,0 +1,3 @@
1
+ App({
2
+ globalData: {},
3
+ })
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/component.json",
3
+ "component": true,
4
+ "styleIsolation": "apply-shared"
5
+ }
@@ -0,0 +1,25 @@
1
+ .platform-card {
2
+ padding: 32rpx;
3
+ background: #fff;
4
+ border: 2rpx solid #d8dee4;
5
+ border-radius: 12rpx;
6
+ }
7
+
8
+ .platform-card__label {
9
+ font-size: 24rpx;
10
+ color: #66717d;
11
+ }
12
+
13
+ .platform-card__value {
14
+ margin-top: 10rpx;
15
+ font-size: 44rpx;
16
+ font-weight: 700;
17
+ color: #0969da;
18
+ }
19
+
20
+ .platform-card__hint {
21
+ margin-top: 18rpx;
22
+ font-size: 26rpx;
23
+ line-height: 1.6;
24
+ color: #3d4852;
25
+ }
@@ -0,0 +1,8 @@
1
+ Component({
2
+ properties: {
3
+ platform: {
4
+ type: String,
5
+ value: 'unknown',
6
+ },
7
+ },
8
+ })
@@ -0,0 +1,5 @@
1
+ <view class="platform-card">
2
+ <view class="platform-card__label">当前构建目标</view>
3
+ <view class="platform-card__value">{{platform}}</view>
4
+ <view class="platform-card__hint">同一份原生源码由 weapp-vite 转换为目标平台产物</view>
5
+ </view>
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/page.json",
3
+ "navigationBarTitleText": "多平台模板",
4
+ "usingComponents": {
5
+ "PlatformCard": "/components/PlatformCard/index"
6
+ }
7
+ }