create-weapp-vite 2.3.4 → 2.3.5

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 (81) hide show
  1. package/README.md +5 -3
  2. package/dist/cli.js +36 -31
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +1 -1
  5. package/dist/{src-2teZ_6MA.js → src-Tx4viskG.js} +20 -8
  6. package/package.json +1 -1
  7. package/templates/default/eslint.config.js +1 -1
  8. package/templates/default/package.json +1 -0
  9. package/templates/default/src/app.scss +1 -0
  10. package/templates/default/src/components/HelloWorld/HelloWorld.scss +10 -10
  11. package/templates/default/src/pages/index/index.scss +1 -0
  12. package/templates/lib/eslint.config.js +1 -1
  13. package/templates/lib/package.json +2 -1
  14. package/templates/lib/src/app.scss +1 -0
  15. package/templates/lib/src/components/HelloWorld/HelloWorld.scss +10 -10
  16. package/templates/lib/src/components/sfc-setup/index.vue +8 -8
  17. package/templates/plugin/.editorconfig +9 -0
  18. package/templates/plugin/README.md +35 -0
  19. package/templates/plugin/eslint.config.js +6 -0
  20. package/templates/plugin/gitignore +36 -0
  21. package/templates/plugin/package.json +45 -0
  22. package/templates/plugin/plugin/components/hello-component/index.vue +174 -0
  23. package/templates/plugin/plugin/components/native-meter/index.json +6 -0
  24. package/templates/plugin/plugin/components/native-meter/index.scss +51 -0
  25. package/templates/plugin/plugin/components/native-meter/index.ts +28 -0
  26. package/templates/plugin/plugin/components/native-meter/index.wxml +12 -0
  27. package/templates/plugin/plugin/index.ts +16 -0
  28. package/templates/plugin/plugin/pages/hello-page/index.vue +332 -0
  29. package/templates/plugin/plugin/pages/native-playground/index.json +7 -0
  30. package/templates/plugin/plugin/pages/native-playground/index.scss +81 -0
  31. package/templates/plugin/plugin/pages/native-playground/index.ts +20 -0
  32. package/templates/plugin/plugin/pages/native-playground/index.wxml +30 -0
  33. package/templates/plugin/plugin/plugin.json +11 -0
  34. package/templates/plugin/plugin/utils/showcase.ts +102 -0
  35. package/templates/plugin/project.config.json +48 -0
  36. package/templates/plugin/project.private.config.json +8 -0
  37. package/templates/plugin/shared/shared-data.ts +12 -0
  38. package/templates/plugin/src/app.json +11 -0
  39. package/templates/plugin/src/app.ts +5 -0
  40. package/templates/plugin/src/pages/index/index.json +6 -0
  41. package/templates/plugin/src/pages/index/index.ts +46 -0
  42. package/templates/plugin/src/pages/index/index.wxml +46 -0
  43. package/templates/plugin/src/pages/index/index.wxss +113 -0
  44. package/templates/plugin/src/sitemap.json +7 -0
  45. package/templates/plugin/stylelint.config.js +5 -0
  46. package/templates/plugin/tsconfig.json +17 -0
  47. package/templates/plugin/weapp-vite.config.ts +23 -0
  48. package/templates/tailwindcss/eslint.config.js +4 -1
  49. package/templates/tailwindcss/package.json +3 -2
  50. package/templates/tailwindcss/postcss.config.js +1 -2
  51. package/templates/tailwindcss/src/app.css +2 -0
  52. package/templates/tailwindcss/src/pages/index/index.scss +1 -0
  53. package/templates/tailwindcss/src/pages/profile/index.scss +1 -0
  54. package/templates/tailwindcss/tailwind.config.ts +0 -5
  55. package/templates/tailwindcss/weapp-vite.config.ts +2 -0
  56. package/templates/tdesign/eslint.config.js +4 -1
  57. package/templates/tdesign/package.json +3 -2
  58. package/templates/tdesign/postcss.config.js +1 -2
  59. package/templates/tdesign/src/app.css +2 -0
  60. package/templates/tdesign/src/pages/index/index.scss +1 -0
  61. package/templates/tdesign/tailwind.config.ts +0 -5
  62. package/templates/tdesign/weapp-vite.config.ts +2 -0
  63. package/templates/vant/eslint.config.js +4 -1
  64. package/templates/vant/package.json +3 -2
  65. package/templates/vant/postcss.config.js +1 -2
  66. package/templates/vant/src/app.css +2 -0
  67. package/templates/vant/src/pages/index/index.scss +1 -0
  68. package/templates/vant/tailwind.config.ts +0 -5
  69. package/templates/vant/weapp-vite.config.ts +2 -0
  70. package/templates/wevu/eslint.config.js +1 -1
  71. package/templates/wevu/package.json +1 -0
  72. package/templates/wevu-tdesign/eslint.config.js +13 -1
  73. package/templates/wevu-tdesign/package.json +3 -2
  74. package/templates/wevu-tdesign/postcss.config.js +1 -2
  75. package/templates/wevu-tdesign/src/app.css +7 -0
  76. package/templates/wevu-tdesign/src/app.vue +1 -10
  77. package/templates/wevu-tdesign/tailwind.config.ts +0 -5
  78. package/templates/wevu-tdesign/weapp-vite.config.ts +1 -0
  79. package/templates/tailwindcss/src/app.scss +0 -3
  80. package/templates/tdesign/src/app.scss +0 -3
  81. package/templates/vant/src/app.scss +0 -3
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  ## 特性
8
8
 
9
9
  - 交互式创建或非交互式参数创建
10
- - 内置多种模板(默认、Wevu、Tailwindcss、TDesign、Vant 等)
10
+ - 内置多种模板(默认、Wevu、Wevu + TDesign、Tailwindcss、TDesign、Vant、插件、组件库)
11
11
  - 自动对齐 `weapp-vite` 与 `wevu` 版本
12
12
  - 自动处理 `.gitignore` 写入
13
13
  - 可选安装推荐的 AI skills(`sonofmagic/skills`)
@@ -67,10 +67,12 @@ await createProject('my-app', TemplateName.wevu, { installSkills: true })
67
67
 
68
68
  - `default`
69
69
  - `wevu`
70
+ - `wevu-tdesign`
70
71
  - `tailwindcss`
71
- - `vant`
72
72
  - `tdesign`
73
- - `wevu-tdesign`
73
+ - `vant`
74
+ - `plugin`
75
+ - `lib`
74
76
 
75
77
  ## 相关链接
76
78
 
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as RECOMMENDED_SKILLS_INSTALL_COMMAND, t as createProject } from "./src-2teZ_6MA.js";
1
+ import { n as RECOMMENDED_SKILLS_INSTALL_COMMAND, t as createProject } from "./src-Tx4viskG.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";
@@ -6,6 +6,40 @@ import path from "node:path";
6
6
  import { confirm, input, select } from "@inquirer/prompts";
7
7
  //#region src/cli.ts
8
8
  const cwd = process.cwd();
9
+ const TEMPLATE_CHOICES = [
10
+ {
11
+ name: "默认模板",
12
+ value: "default"
13
+ },
14
+ {
15
+ name: "Wevu 模板 (Vue SFC)",
16
+ value: "wevu"
17
+ },
18
+ {
19
+ name: "Wevu + TDesign 模板 (wevu + tdesign + tailwindcss)",
20
+ value: "wevu-tdesign"
21
+ },
22
+ {
23
+ name: "集成 Tailwindcss",
24
+ value: "tailwindcss"
25
+ },
26
+ {
27
+ name: "TDesign 模板 (tdesign + tailwindcss)",
28
+ value: "tdesign"
29
+ },
30
+ {
31
+ name: "Vant 模板 (vant + tailwindcss)",
32
+ value: "vant"
33
+ },
34
+ {
35
+ name: "插件模板 (src + pluginRoot)",
36
+ value: "plugin"
37
+ },
38
+ {
39
+ name: "组件库模板 (lib 模式)",
40
+ value: "lib"
41
+ }
42
+ ];
9
43
  function parseCliArgs(argv) {
10
44
  const positionals = [];
11
45
  let installSkills;
@@ -42,36 +76,7 @@ async function run() {
42
76
  }
43
77
  await createProject(targetDir, isArgMode ? argTemplate ?? "default" : await select({
44
78
  message: "选择模板",
45
- choices: [
46
- {
47
- name: "默认模板",
48
- value: "default"
49
- },
50
- {
51
- name: "组件库模板 (lib 模式)",
52
- value: "lib"
53
- },
54
- {
55
- name: "Wevu 模板 (Vue SFC)",
56
- value: "wevu"
57
- },
58
- {
59
- name: "Wevu + TDesign 模板 (wevu + tdesign + tailwindcss)",
60
- value: "wevu-tdesign"
61
- },
62
- {
63
- name: "集成 Tailwindcss",
64
- value: "tailwindcss"
65
- },
66
- {
67
- name: "Vant 模板 (vant + tailwindcss)",
68
- value: "vant"
69
- },
70
- {
71
- name: "TDesign 模板 (tdesign + tailwindcss)",
72
- value: "tdesign"
73
- }
74
- ],
79
+ choices: TEMPLATE_CHOICES,
75
80
  default: "default"
76
81
  }), { installSkills: isArgMode ? argInstallSkills ?? false : await confirm({
77
82
  message: `是否安装推荐的 AI skills?将执行 \`${RECOMMENDED_SKILLS_INSTALL_COMMAND}\`,也可稍后手动执行`,
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  //#region src/enums.d.ts
2
2
  declare enum TemplateName {
3
3
  default = "default",
4
+ plugin = "plugin",
4
5
  wevu = "wevu",
5
6
  tailwindcss = "tailwindcss",
6
7
  vant = "vant",
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { r as TemplateName, t as createProject } from "./src-2teZ_6MA.js";
1
+ import { r as TemplateName, t as createProject } from "./src-Tx4viskG.js";
2
2
  export { TemplateName, createProject };
@@ -6,14 +6,15 @@ import https from "node:https";
6
6
  import { spawn } from "node:child_process";
7
7
  import process from "node:process";
8
8
  //#region ../../packages-runtime/wevu/package.json
9
- var version$1 = "6.15.11";
9
+ var version$1 = "6.15.12";
10
10
  //#endregion
11
11
  //#region ../weapp-vite/package.json
12
- var version = "6.15.11";
12
+ var version = "6.15.12";
13
13
  //#endregion
14
14
  //#region src/enums.ts
15
15
  let TemplateName = /* @__PURE__ */ function(TemplateName) {
16
16
  TemplateName["default"] = "default";
17
+ TemplateName["plugin"] = "plugin";
17
18
  TemplateName["wevu"] = "wevu";
18
19
  TemplateName["tailwindcss"] = "tailwindcss";
19
20
  TemplateName["vant"] = "vant";
@@ -30,6 +31,9 @@ function supportsWevu(templateName) {
30
31
  function supportsNativePages(templateName) {
31
32
  return !supportsWevu(templateName);
32
33
  }
34
+ function supportsPlugin(templateName) {
35
+ return templateName === "plugin";
36
+ }
33
37
  /**
34
38
  * @description 生成新项目的 AGENTS 指引
35
39
  */
@@ -85,6 +89,7 @@ function createAgentsGuidelines(templateName) {
85
89
  ];
86
90
  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.");
87
91
  if (supportsNativePages(templateName)) lines.push(" - `$native-to-weapp-vite-wevu-migration` when migrating native mini-program pages/components toward Vue SFC or 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 toward Vue SFC or `wevu`, keep the migration explicit and prefer the official weapp-vite / wevu guidance first.");
92
+ 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.");
88
93
  return `${lines.join("\n")}\n`;
89
94
  }
90
95
  //#endregion
@@ -101,8 +106,8 @@ const TEMPLATE_CATALOG = {
101
106
  "@icebreakers/stylelint-config": "^3.0.5",
102
107
  "@iconify-json/mdi": "^1.2.3",
103
108
  "@mini-types/alipay": "^3.0.14",
104
- "@tailwindcss/postcss": "^4.2.2",
105
- "@tailwindcss/vite": "^4.2.2",
109
+ "@tailwindcss/postcss": "^4.2.4",
110
+ "@tailwindcss/vite": "^4.2.4",
106
111
  "@types/node": "^25.6.0",
107
112
  "@types/semver": "^7.7.1",
108
113
  "@vant/weapp": "^1.11.7",
@@ -119,7 +124,7 @@ const TEMPLATE_CATALOG = {
119
124
  "lru-cache": "^11.3.5",
120
125
  "magic-string": "^0.30.21",
121
126
  "miniprogram-api-typings": "^5.1.2",
122
- "oxc-parser": "^0.126.0",
127
+ "oxc-parser": "^0.127.0",
123
128
  "oxc-walker": "^0.7.0",
124
129
  "pkg-types": "^2.3.0",
125
130
  "sass-embedded": "^1.99.0",
@@ -146,7 +151,7 @@ const TEMPLATE_CATALOG = {
146
151
  rolldown: "1.0.0-rc.16",
147
152
  sass: "^1.99.0",
148
153
  stylelint: "^17.8.0",
149
- tailwindcss: "^4.2.2",
154
+ tailwindcss: "^4.2.4",
150
155
  tslib: "^2.8.1",
151
156
  typescript: "^6.0.3",
152
157
  vite: "8.0.9",
@@ -160,8 +165,8 @@ const TEMPLATE_NAMED_CATALOG = {
160
165
  "miniprogram-api-typings": "^5.1.2",
161
166
  typescript: "^6.0.3"
162
167
  },
163
- tailwind3: { tailwindcss: "3.4.19" },
164
- tailwind4: { tailwindcss: "^4.2.2" }
168
+ tailwind3: { tailwindcss: "^4.2.4" },
169
+ tailwind4: { tailwindcss: "^4.2.4" }
165
170
  };
166
171
  //#endregion
167
172
  //#region src/npm.ts
@@ -379,6 +384,7 @@ const TOURIST_APP_ID = "touristappid";
379
384
  const moduleDir = path.dirname(fileURLToPath(import.meta.url));
380
385
  const TEMPLATE_DIR_MAP = {
381
386
  ["default"]: "weapp-vite-template",
387
+ ["plugin"]: "weapp-vite-plugin-template",
382
388
  ["lib"]: "weapp-vite-lib-template",
383
389
  ["wevu"]: "weapp-vite-wevu-template",
384
390
  ["wevu-tdesign"]: "weapp-vite-wevu-tailwindcss-tdesign-template",
@@ -516,6 +522,11 @@ function normalizeTemplateDependencySpecs(pkgJson) {
516
522
  }
517
523
  }
518
524
  }
525
+ function ensureManagedTypeScriptDevDependencies(pkgJson) {
526
+ pkgJson.devDependencies ??= {};
527
+ if (pkgJson.dependencies?.["@types/node"] || pkgJson.devDependencies["@types/node"] || pkgJson.peerDependencies?.["@types/node"] || pkgJson.optionalDependencies?.["@types/node"]) return;
528
+ pkgJson.devDependencies["@types/node"] = templateCatalogMap["@types/node"];
529
+ }
519
530
  /**
520
531
  * @description 根据模板创建项目
521
532
  */
@@ -538,6 +549,7 @@ async function createProject(targetDir = "", templateName = "default", options =
538
549
  }
539
550
  const pkgJson = await fs.pathExists(templatePackagePath) ? await fs.readJSON(templatePackagePath) : createEmptyPackageJson();
540
551
  normalizeTemplateDependencySpecs(pkgJson);
552
+ ensureManagedTypeScriptDevDependencies(pkgJson);
541
553
  if (!pkgJson.devDependencies) pkgJson.devDependencies = {};
542
554
  upsertExistingDependencyVersion(pkgJson, "weapp-vite", toCaretVersion(version));
543
555
  upsertExistingDependencyVersion(pkgJson, "wevu", toCaretVersion(version$1));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-weapp-vite",
3
3
  "type": "module",
4
- "version": "2.3.4",
4
+ "version": "2.3.5",
5
5
  "description": "create-weapp-vite",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -2,5 +2,5 @@ import { icebreaker } from '@icebreakers/eslint-config'
2
2
 
3
3
  export default icebreaker({
4
4
  miniProgram: true,
5
- ignores: ['CHANGELOG.md', 'README.md', '.turbo/**'],
5
+ ignores: ['CHANGELOG.md', 'README.md', '.turbo/**', 'dist/**', '.weapp-vite/**'],
6
6
  })
@@ -30,6 +30,7 @@
30
30
  "devDependencies": {
31
31
  "@icebreakers/eslint-config": "catalog:",
32
32
  "@icebreakers/stylelint-config": "catalog:",
33
+ "@types/node": "catalog:",
33
34
  "eslint": "catalog:",
34
35
  "miniprogram-api-typings": "catalog:",
35
36
  "sass": "catalog:",
@@ -0,0 +1 @@
1
+ /* empty */
@@ -1,13 +1,13 @@
1
1
  .hello-card {
2
- width: 640rpx;
3
- margin: 48rpx auto;
4
- padding: 32rpx;
5
- border-radius: 32rpx;
6
- background: #ffffff;
7
- box-shadow: 0 20rpx 60rpx rgba(15, 23, 42, 0.08);
8
2
  display: flex;
9
3
  flex-direction: column;
10
4
  gap: 24rpx;
5
+ width: 640rpx;
6
+ padding: 32rpx;
7
+ margin: 48rpx auto;
8
+ background: #fff;
9
+ border-radius: 32rpx;
10
+ box-shadow: 0 20rpx 60rpx rgb(15 23 42 / 8%);
11
11
  }
12
12
 
13
13
  .hello-title {
@@ -30,15 +30,15 @@
30
30
 
31
31
  .hello-button {
32
32
  padding: 16rpx 32rpx;
33
- border-radius: 999rpx;
34
- background: #2563eb;
35
- color: #ffffff;
36
33
  font-size: 26rpx;
34
+ color: #fff;
35
+ background: #2563eb;
36
+ border-radius: 999rpx;
37
37
  }
38
38
 
39
39
  .hello-button--ghost {
40
- background: #e2e8f0;
41
40
  color: #1e293b;
41
+ background: #e2e8f0;
42
42
  }
43
43
 
44
44
  .hello-tip {
@@ -0,0 +1 @@
1
+ /* empty */
@@ -3,5 +3,5 @@ import { icebreaker } from '@icebreakers/eslint-config'
3
3
  export default icebreaker({
4
4
  miniProgram: true,
5
5
  vue: true,
6
- ignores: ['CHANGELOG.md', 'README.md', 'dist-lib/**', '.turbo/**'],
6
+ ignores: ['CHANGELOG.md', 'README.md', '.turbo/**', 'dist/**', 'dist-lib/**', '.weapp-vite/**'],
7
7
  })
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite-lib-template",
3
3
  "type": "module",
4
- "version": "6.0.11",
4
+ "version": "6.0.12",
5
5
  "private": true,
6
6
  "description": "weapp-vite 组件库(lib 模式)模板",
7
7
  "author": "ice breaker <1324318532@qq.com>",
@@ -34,6 +34,7 @@
34
34
  "devDependencies": {
35
35
  "@icebreakers/eslint-config": "catalog:",
36
36
  "@icebreakers/stylelint-config": "catalog:",
37
+ "@types/node": "catalog:",
37
38
  "eslint": "catalog:",
38
39
  "miniprogram-api-typings": "catalog:",
39
40
  "sass": "catalog:",
@@ -0,0 +1 @@
1
+ /* empty */
@@ -1,13 +1,13 @@
1
1
  .hello-card {
2
- width: 640rpx;
3
- margin: 48rpx auto;
4
- padding: 32rpx;
5
- border-radius: 32rpx;
6
- background: #ffffff;
7
- box-shadow: 0 20rpx 60rpx rgba(15, 23, 42, 0.08);
8
2
  display: flex;
9
3
  flex-direction: column;
10
4
  gap: 24rpx;
5
+ width: 640rpx;
6
+ padding: 32rpx;
7
+ margin: 48rpx auto;
8
+ background: #fff;
9
+ border-radius: 32rpx;
10
+ box-shadow: 0 20rpx 60rpx rgb(15 23 42 / 8%);
11
11
  }
12
12
 
13
13
  .hello-title {
@@ -30,15 +30,15 @@
30
30
 
31
31
  .hello-button {
32
32
  padding: 16rpx 32rpx;
33
- border-radius: 999rpx;
34
- background: #2563eb;
35
- color: #ffffff;
36
33
  font-size: 26rpx;
34
+ color: #fff;
35
+ background: #2563eb;
36
+ border-radius: 999rpx;
37
37
  }
38
38
 
39
39
  .hello-button--ghost {
40
- background: #e2e8f0;
41
40
  color: #1e293b;
41
+ background: #e2e8f0;
42
42
  }
43
43
 
44
44
  .hello-tip {
@@ -77,9 +77,9 @@ defineExpose({
77
77
  <style>
78
78
  .card {
79
79
  padding: 20rpx;
80
- border-radius: 16rpx;
81
- border: 2rpx solid transparent;
82
80
  background: #eff6ff;
81
+ border: 2rpx solid transparent;
82
+ border-radius: 16rpx;
83
83
  }
84
84
 
85
85
  .title {
@@ -102,16 +102,16 @@ defineExpose({
102
102
 
103
103
  .btn {
104
104
  padding: 8rpx 16rpx;
105
- border-radius: 999rpx;
106
- border: 2rpx solid #1d4ed8;
107
- background: #1d4ed8;
108
- color: #eff6ff;
109
105
  font-size: 22rpx;
106
+ color: #eff6ff;
107
+ background: #1d4ed8;
108
+ border: 2rpx solid #1d4ed8;
109
+ border-radius: 999rpx;
110
110
  }
111
111
 
112
112
  .btn.ghost {
113
- background: transparent;
114
113
  color: #1d4ed8;
114
+ background: transparent;
115
115
  }
116
116
 
117
117
  .tone-info {
@@ -142,7 +142,7 @@ defineExpose({
142
142
  }
143
143
 
144
144
  .is-active {
145
- box-shadow: 0 0 0 4rpx rgba(29, 78, 216, 0.2);
145
+ box-shadow: 0 0 0 4rpx rgb(29 78 216 / 20%);
146
146
  }
147
147
 
148
148
  .has-count .title {
@@ -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,35 @@
1
+ # weapp-vite-plugin-template
2
+
3
+ `weapp-vite` 小程序插件模板,内置宿主小程序、`pluginRoot` 和共享 TS 模块示例。
4
+
5
+ ## 使用方式
6
+
7
+ ### 开发
8
+
9
+ - `pnpm dev`
10
+ - `pnpm dev:open` 可以打包并直接启动微信开发者工具
11
+
12
+ ### 构建
13
+
14
+ `pnpm build`
15
+
16
+ ### 打开微信开发者工具
17
+
18
+ `pnpm open`
19
+
20
+ ## 目录说明
21
+
22
+ - `src/`: 宿主小程序源码
23
+ - `plugin/`: 插件源码,包含 `plugin.json`、公开组件与页面
24
+ - `shared/`: 主包与插件共享的 TypeScript 模块
25
+
26
+ ## 使用提示
27
+
28
+ - 模板默认通过 `weapp.pluginRoot` 输出 `dist-plugin/**`
29
+ - `src/app.json` 里预置了 `hello-plugin` 的 `provider`
30
+ - 如果你要在自己的插件 AppID 下调试或上传,请先替换 `project.config.json` 的 `appid`,并同步修改 `src/app.json` 里的 `plugins.hello-plugin.provider`
31
+
32
+ ## 文档地址
33
+
34
+ 0. `weapp-vite`: https://vite.icebreaker.top/
35
+ 1. 插件开发说明: https://vite.icebreaker.top/guide/plugin
@@ -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/**', 'dist-plugin/**', '.weapp-vite/**'],
6
+ })
@@ -0,0 +1,36 @@
1
+ # dependencies
2
+ node_modules
3
+ .pnp
4
+ .pnp.js
5
+
6
+ # testing
7
+ coverage
8
+
9
+ # next.js
10
+ .next/
11
+ out/
12
+ build
13
+
14
+ # misc
15
+ .DS_Store
16
+ *.pem
17
+
18
+ # debug
19
+ npm-debug.log*
20
+ yarn-debug.log*
21
+ yarn-error.log*
22
+ .pnpm-debug.log*
23
+
24
+ # local env files
25
+ .env.local
26
+ .env.development.local
27
+ .env.test.local
28
+ .env.production.local
29
+
30
+ # turbo
31
+ .turbo
32
+
33
+ dist
34
+ vite.config.ts.timestamp-*.mjs
35
+ dist-web
36
+ .weapp-vite/
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "weapp-vite-plugin-template",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "private": true,
6
+ "description": "微信小程序插件模板",
7
+ "author": "ice breaker <1324318532@qq.com>",
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/weapp-vite/weapp-vite.git",
12
+ "directory": "templates/weapp-vite-plugin-template"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/weapp-vite/weapp-vite/issues"
16
+ },
17
+ "keywords": [],
18
+ "scripts": {
19
+ "dev": "wv dev",
20
+ "dev:open": "wv dev -o",
21
+ "build": "wv build",
22
+ "lint": "eslint .",
23
+ "lint:fix": "eslint . --fix",
24
+ "open": "wv open",
25
+ "stylelint": "stylelint \"{src,plugin,shared}/**/*.{css,scss,vue,wxss}\" --allow-empty-input",
26
+ "stylelint:fix": "stylelint \"{src,plugin,shared}/**/*.{css,scss,vue,wxss}\" --fix --allow-empty-input",
27
+ "g": "wv generate",
28
+ "postinstall": "wv prepare"
29
+ },
30
+ "dependencies": {
31
+ "dayjs": "catalog:"
32
+ },
33
+ "devDependencies": {
34
+ "@icebreakers/eslint-config": "catalog:",
35
+ "@icebreakers/stylelint-config": "catalog:",
36
+ "@types/node": "catalog:",
37
+ "eslint": "catalog:",
38
+ "miniprogram-api-typings": "catalog:",
39
+ "sass": "catalog:",
40
+ "stylelint": "catalog:",
41
+ "typescript": "catalog:",
42
+ "weapp-vite": "workspace:*",
43
+ "wevu": "workspace:*"
44
+ }
45
+ }