@weapp-core/init 1.1.11 → 1.1.12

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 (66) hide show
  1. package/dist/index.cjs +13 -4
  2. package/dist/index.d.cts +7 -2
  3. package/dist/index.d.ts +7 -2
  4. package/dist/index.js +11 -3
  5. package/package.json +1 -1
  6. package/templates/default/package.json +2 -2
  7. package/templates/tdesign/.editorconfig +9 -0
  8. package/templates/tdesign/.vscode/settings.json +5 -0
  9. package/templates/tdesign/README.md +28 -0
  10. package/templates/tdesign/package.json +41 -0
  11. package/templates/tdesign/postcss.config.js +6 -0
  12. package/templates/tdesign/project.config.json +42 -0
  13. package/templates/tdesign/project.private.config.json +7 -0
  14. package/templates/tdesign/src/app.json +11 -0
  15. package/templates/tdesign/src/app.scss +3 -0
  16. package/templates/tdesign/src/app.ts +6 -0
  17. package/templates/tdesign/src/components/navigation-bar/navigation-bar.json +7 -0
  18. package/templates/tdesign/src/components/navigation-bar/navigation-bar.scss +0 -0
  19. package/templates/tdesign/src/components/navigation-bar/navigation-bar.ts +3 -0
  20. package/templates/tdesign/src/components/navigation-bar/navigation-bar.wxml +0 -0
  21. package/templates/tdesign/src/pages/index/index.json +7 -0
  22. package/templates/tdesign/src/pages/index/index.scss +0 -0
  23. package/templates/tdesign/src/pages/index/index.ts +78 -0
  24. package/templates/tdesign/src/pages/index/index.wxml +23 -0
  25. package/templates/tdesign/src/pages/logs/logs.json +6 -0
  26. package/templates/tdesign/src/pages/logs/logs.scss +0 -0
  27. package/templates/tdesign/src/pages/logs/logs.ts +3 -0
  28. package/templates/tdesign/src/pages/logs/logs.wxml +0 -0
  29. package/templates/tdesign/src/sitemap.json +10 -0
  30. package/templates/tdesign/src/theme.json +5 -0
  31. package/templates/tdesign/src/utils/util.ts +3 -0
  32. package/templates/tdesign/src/vite-env.d.ts +1 -0
  33. package/templates/tdesign/tailwind.config.ts +22 -0
  34. package/templates/tdesign/tsconfig.json +47 -0
  35. package/templates/tdesign/tsconfig.node.json +13 -0
  36. package/templates/tdesign/vite.config.ts +43 -0
  37. package/templates/vant/.editorconfig +9 -0
  38. package/templates/vant/.vscode/settings.json +5 -0
  39. package/templates/vant/README.md +28 -0
  40. package/templates/vant/package.json +41 -0
  41. package/templates/vant/postcss.config.js +6 -0
  42. package/templates/vant/project.config.json +42 -0
  43. package/templates/vant/project.private.config.json +7 -0
  44. package/templates/vant/src/app.json +11 -0
  45. package/templates/vant/src/app.scss +3 -0
  46. package/templates/vant/src/app.ts +6 -0
  47. package/templates/vant/src/components/navigation-bar/navigation-bar.json +7 -0
  48. package/templates/vant/src/components/navigation-bar/navigation-bar.scss +0 -0
  49. package/templates/vant/src/components/navigation-bar/navigation-bar.ts +3 -0
  50. package/templates/vant/src/components/navigation-bar/navigation-bar.wxml +0 -0
  51. package/templates/vant/src/pages/index/index.json +7 -0
  52. package/templates/vant/src/pages/index/index.scss +0 -0
  53. package/templates/vant/src/pages/index/index.ts +39 -0
  54. package/templates/vant/src/pages/index/index.wxml +22 -0
  55. package/templates/vant/src/pages/logs/logs.json +6 -0
  56. package/templates/vant/src/pages/logs/logs.scss +0 -0
  57. package/templates/vant/src/pages/logs/logs.ts +3 -0
  58. package/templates/vant/src/pages/logs/logs.wxml +0 -0
  59. package/templates/vant/src/sitemap.json +10 -0
  60. package/templates/vant/src/theme.json +5 -0
  61. package/templates/vant/src/utils/util.ts +3 -0
  62. package/templates/vant/src/vite-env.d.ts +1 -0
  63. package/templates/vant/tailwind.config.ts +22 -0
  64. package/templates/vant/tsconfig.json +49 -0
  65. package/templates/vant/tsconfig.node.json +13 -0
  66. package/templates/vant/vite.config.ts +43 -0
package/dist/index.cjs CHANGED
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
+ TemplateName: () => TemplateName,
33
34
  createOrUpdatePackageJson: () => createOrUpdatePackageJson,
34
35
  createOrUpdateProjectConfig: () => createOrUpdateProjectConfig,
35
36
  createProject: () => createProject,
@@ -40,7 +41,7 @@ __export(src_exports, {
40
41
  });
41
42
  module.exports = __toCommonJS(src_exports);
42
43
 
43
- // ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.9.3_jiti@2.4.0_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/cjs_shims.js
44
+ // ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.10.1_jiti@2.4.0_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/cjs_shims.js
44
45
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
45
46
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
46
47
 
@@ -541,6 +542,7 @@ async function createOrUpdatePackageJson(options) {
541
542
  }
542
543
  try {
543
544
  (0, import_shared.set)(packageJson, "scripts.dev", `${command} dev`);
545
+ (0, import_shared.set)(packageJson, "scripts.dev:open", `${command} dev -o`);
544
546
  (0, import_shared.set)(packageJson, "scripts.build", `${command} build`);
545
547
  if (command === "weapp-vite") {
546
548
  (0, import_shared.set)(packageJson, "scripts.open", `${command} open`);
@@ -644,8 +646,14 @@ async function initConfig(options) {
644
646
  }
645
647
  return ctx;
646
648
  }
647
- async function createProject(targetDir = "", templateDirName = "default") {
648
- const targetTemplateDir = path.resolve(__dirname, "../templates", templateDirName);
649
+ var TemplateName = /* @__PURE__ */ ((TemplateName2) => {
650
+ TemplateName2["default"] = "default";
651
+ TemplateName2["vant"] = "vant";
652
+ TemplateName2["tdesign"] = "tdesign";
653
+ return TemplateName2;
654
+ })(TemplateName || {});
655
+ async function createProject(targetDir = "", templateName = "default" /* default */) {
656
+ const targetTemplateDir = path.resolve(__dirname, "../templates", templateName);
649
657
  if (await import_fs_extra.default.exists(targetTemplateDir)) {
650
658
  await import_fs_extra.default.copy(targetTemplateDir, targetDir);
651
659
  const pkgJsonPath = path.resolve(targetTemplateDir, "package.json");
@@ -657,11 +665,12 @@ async function createProject(targetDir = "", templateDirName = "default") {
657
665
  await import_fs_extra.default.writeJson(path.resolve(targetDir, "package.json"), pkgJson, { spaces: 2 });
658
666
  import_logger.default.log(`\u2728 \u521B\u5EFA\u6A21\u677F\u6210\u529F!`);
659
667
  } else {
660
- import_logger.default.warn(`\u6CA1\u6709\u627E\u5230 ${templateDirName} \u6A21\u677F!`);
668
+ import_logger.default.warn(`\u6CA1\u6709\u627E\u5230 ${templateName} \u6A21\u677F!`);
661
669
  }
662
670
  }
663
671
  // Annotate the CommonJS export names for ESM import in node:
664
672
  0 && (module.exports = {
673
+ TemplateName,
665
674
  createOrUpdatePackageJson,
666
675
  createOrUpdateProjectConfig,
667
676
  createProject,
package/dist/index.d.cts CHANGED
@@ -70,6 +70,11 @@ declare function initConfig(options: {
70
70
  value: string;
71
71
  };
72
72
  }>;
73
- declare function createProject(targetDir?: string, templateDirName?: string): Promise<void>;
73
+ declare enum TemplateName {
74
+ default = "default",
75
+ vant = "vant",
76
+ tdesign = "tdesign"
77
+ }
78
+ declare function createProject(targetDir?: string, templateName?: TemplateName): Promise<void>;
74
79
 
75
- export { createOrUpdatePackageJson, createOrUpdateProjectConfig, createProject, initConfig, initTsDtsFile, initTsJsonFiles, initViteConfigFile };
80
+ export { TemplateName, createOrUpdatePackageJson, createOrUpdateProjectConfig, createProject, initConfig, initTsDtsFile, initTsJsonFiles, initViteConfigFile };
package/dist/index.d.ts CHANGED
@@ -70,6 +70,11 @@ declare function initConfig(options: {
70
70
  value: string;
71
71
  };
72
72
  }>;
73
- declare function createProject(targetDir?: string, templateDirName?: string): Promise<void>;
73
+ declare enum TemplateName {
74
+ default = "default",
75
+ vant = "vant",
76
+ tdesign = "tdesign"
77
+ }
78
+ declare function createProject(targetDir?: string, templateName?: TemplateName): Promise<void>;
74
79
 
75
- export { createOrUpdatePackageJson, createOrUpdateProjectConfig, createProject, initConfig, initTsDtsFile, initTsJsonFiles, initViteConfigFile };
80
+ export { TemplateName, createOrUpdatePackageJson, createOrUpdateProjectConfig, createProject, initConfig, initTsDtsFile, initTsJsonFiles, initViteConfigFile };
package/dist/index.js CHANGED
@@ -495,6 +495,7 @@ async function createOrUpdatePackageJson(options) {
495
495
  }
496
496
  try {
497
497
  set(packageJson, "scripts.dev", `${command} dev`);
498
+ set(packageJson, "scripts.dev:open", `${command} dev -o`);
498
499
  set(packageJson, "scripts.build", `${command} build`);
499
500
  if (command === "weapp-vite") {
500
501
  set(packageJson, "scripts.open", `${command} open`);
@@ -598,8 +599,14 @@ async function initConfig(options) {
598
599
  }
599
600
  return ctx;
600
601
  }
601
- async function createProject(targetDir = "", templateDirName = "default") {
602
- const targetTemplateDir = path.resolve(__dirname2, "../templates", templateDirName);
602
+ var TemplateName = /* @__PURE__ */ ((TemplateName2) => {
603
+ TemplateName2["default"] = "default";
604
+ TemplateName2["vant"] = "vant";
605
+ TemplateName2["tdesign"] = "tdesign";
606
+ return TemplateName2;
607
+ })(TemplateName || {});
608
+ async function createProject(targetDir = "", templateName = "default" /* default */) {
609
+ const targetTemplateDir = path.resolve(__dirname2, "../templates", templateName);
603
610
  if (await fs.exists(targetTemplateDir)) {
604
611
  await fs.copy(targetTemplateDir, targetDir);
605
612
  const pkgJsonPath = path.resolve(targetTemplateDir, "package.json");
@@ -611,10 +618,11 @@ async function createProject(targetDir = "", templateDirName = "default") {
611
618
  await fs.writeJson(path.resolve(targetDir, "package.json"), pkgJson, { spaces: 2 });
612
619
  logger.log(`\u2728 \u521B\u5EFA\u6A21\u677F\u6210\u529F!`);
613
620
  } else {
614
- logger.warn(`\u6CA1\u6709\u627E\u5230 ${templateDirName} \u6A21\u677F!`);
621
+ logger.warn(`\u6CA1\u6709\u627E\u5230 ${templateName} \u6A21\u677F!`);
615
622
  }
616
623
  }
617
624
  export {
625
+ TemplateName,
618
626
  createOrUpdatePackageJson,
619
627
  createOrUpdateProjectConfig,
620
628
  createProject,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-core/init",
3
3
  "type": "module",
4
- "version": "1.1.11",
4
+ "version": "1.1.12",
5
5
  "description": "@weapp-core/init",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -29,8 +29,8 @@
29
29
  "autoprefixer": "^10.4.20",
30
30
  "miniprogram-api-typings": "^4.0.2",
31
31
  "postcss": "^8.4.49",
32
- "sass": "^1.81.0",
33
- "tailwindcss": "^3.4.15",
32
+ "sass": "^1.83.0",
33
+ "tailwindcss": "^3.4.16",
34
34
  "typescript": "^5.7.2",
35
35
  "weapp-tailwindcss": "^3.7.0",
36
36
  "weapp-vite": "workspace:*"
@@ -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,5 @@
1
+ {
2
+ "tailwindCSS.includeLanguages": {
3
+ "wxml": "html"
4
+ }
5
+ }
@@ -0,0 +1,28 @@
1
+ # weapp-vite-tailwindcss-tdesign-template
2
+
3
+ `weapp-vite` 集成 `tailwindcss`, `tdesign` 的模板
4
+
5
+ ## 使用方式
6
+
7
+ ### 开发
8
+
9
+ - `pnpm dev`
10
+
11
+ - `pnpm dev --open` 可以打包并直接启动微信开发者工具
12
+
13
+ ### 构建
14
+
15
+ `pnpm build`
16
+
17
+ ### 打开微信开发者工具
18
+
19
+ `pnpm open`
20
+
21
+ ### 生成组件/页面
22
+
23
+ `pnpm g path/to/your/component`
24
+
25
+ ## 文档地址
26
+
27
+ 0. `weapp-vite`: https://vite.icebreaker.top/
28
+ 1. `weapp-tailwindcss`: https://tw.icebreaker.top/
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "weapp-vite-tailwindcss-tdesign-template",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "private": true,
6
+ "description": "原生微信小程序 weapp-vite + tailwindcss + tdesign 模板",
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": "apps/weapp-vite-tailwindcss-tdesign-template"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/weapp-vite/weapp-vite/issues"
16
+ },
17
+ "keywords": [],
18
+ "scripts": {
19
+ "dev": "weapp-vite dev",
20
+ "dev:open": "weapp-vite dev -o",
21
+ "build": "weapp-vite build",
22
+ "open": "weapp-vite open",
23
+ "g": "weapp-vite generate",
24
+ "postinstall": "weapp-tw patch"
25
+ },
26
+ "devDependencies": {
27
+ "@egoist/tailwindcss-icons": "^1.8.1",
28
+ "@iconify-json/mdi": "^1.2.1",
29
+ "autoprefixer": "^10.4.20",
30
+ "miniprogram-api-typings": "^4.0.2",
31
+ "postcss": "^8.4.49",
32
+ "sass": "^1.83.0",
33
+ "tailwindcss": "^3.4.16",
34
+ "typescript": "^5.7.2",
35
+ "weapp-tailwindcss": "^3.7.0",
36
+ "weapp-vite": "workspace:*"
37
+ },
38
+ "dependencies": {
39
+ "tdesign-miniprogram": "^1.8.2"
40
+ }
41
+ }
@@ -0,0 +1,6 @@
1
+ export default {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "description": "项目配置文件",
3
+ "miniprogramRoot": "dist/",
4
+ "compileType": "miniprogram",
5
+ "setting": {
6
+ "babelSetting": {
7
+ "ignore": [],
8
+ "disablePlugins": [],
9
+ "outputPath": ""
10
+ },
11
+ "coverView": false,
12
+ "postcss": false,
13
+ "minified": false,
14
+ "enhance": true,
15
+ "showShadowRootInWxmlPanel": false,
16
+ "packNpmRelationList": [
17
+ {
18
+ "packageJsonPath": "./package.json",
19
+ "miniprogramNpmDistDir": "./dist"
20
+ }
21
+ ],
22
+ "ignoreUploadUnusedFiles": true,
23
+ "compileHotReLoad": false,
24
+ "skylineRenderEnable": true,
25
+ "packNpmManually": true,
26
+ "es6": true
27
+ },
28
+ "simulatorType": "wechat",
29
+ "simulatorPluginLibVersion": {},
30
+ "condition": {},
31
+ "srcMiniprogramRoot": "dist/",
32
+ "editorSetting": {
33
+ "tabIndent": "insertSpaces",
34
+ "tabSize": 2
35
+ },
36
+ "libVersion": "2.32.3",
37
+ "packOptions": {
38
+ "ignore": [],
39
+ "include": []
40
+ },
41
+ "appid": "wx6ffee4673b257014"
42
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
3
+ "projectname": "weapp-vite-tailwindcss-template",
4
+ "setting": {
5
+ "compileHotReLoad": false
6
+ }
7
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/app.json",
3
+ "pages": [
4
+ "pages/index/index",
5
+ "pages/logs/logs"
6
+ ],
7
+ "window": {},
8
+ "componentFramework": "glass-easel",
9
+ "sitemapLocation": "sitemap.json",
10
+ "lazyCodeLoading": "requiredComponents"
11
+ }
@@ -0,0 +1,3 @@
1
+ @use 'tailwindcss/base';
2
+ @use 'tailwindcss/components';
3
+ @use 'tailwindcss/utilities';
@@ -0,0 +1,6 @@
1
+ App({
2
+ globalData: {},
3
+ onLaunch() {
4
+
5
+ },
6
+ })
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/component.json",
3
+ "component": true,
4
+ // 组件需要设置成 "apply-shared" 才能使用 app.wxss 里的全局样式
5
+ "styleIsolation": "apply-shared",
6
+ "usingComponents": {}
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/page.json",
3
+ "usingComponents": {
4
+ "navigation-bar": "/components/navigation-bar/navigation-bar"
5
+ },
6
+ "navigationBarTitleText": "初始模板"
7
+ }
File without changes
@@ -0,0 +1,78 @@
1
+ import { hello } from '@/utils/util'
2
+ import ActionSheet, { ActionSheetTheme } from 'tdesign-miniprogram/action-sheet/index'
3
+
4
+ const firstGrid = [
5
+ {
6
+ label: '微信',
7
+ image: 'https://tdesign.gtimg.com/mobile/demos/wechat.png',
8
+ },
9
+ {
10
+ label: '朋友圈',
11
+ image: 'https://tdesign.gtimg.com/mobile/demos/times.png',
12
+ },
13
+ {
14
+ label: 'QQ',
15
+ image: 'https://tdesign.gtimg.com/mobile/demos/qq.png',
16
+ },
17
+ {
18
+ label: '企业微信',
19
+ image: 'https://tdesign.gtimg.com/mobile/demos/wecom.png',
20
+ },
21
+ {
22
+ label: '收藏',
23
+ icon: 'star',
24
+ },
25
+ {
26
+ label: '刷新',
27
+ icon: 'refresh',
28
+ },
29
+ {
30
+ label: '下载',
31
+ icon: 'download',
32
+ },
33
+ {
34
+ label: '复制',
35
+ icon: 'queue',
36
+ },
37
+ ]
38
+ Page({
39
+ data: {
40
+ mode: 'light',
41
+ },
42
+ switchMode() {
43
+ if (this.data.mode === 'light') {
44
+ this.setData({
45
+ mode: 'dark',
46
+ })
47
+ }
48
+ else {
49
+ this.setData({
50
+ mode: 'light',
51
+ })
52
+ }
53
+ },
54
+ async copy(e: WechatMiniprogram.BaseEvent) {
55
+ if (e.mark?.url) {
56
+ await wx.setClipboardData({
57
+ data: e.mark.url,
58
+ })
59
+ console.log(`复制成功: ${e.mark.url}`)
60
+ }
61
+ },
62
+ handleSelected(e: WechatMiniprogram.CustomEvent) {
63
+ console.log(e.detail)
64
+ },
65
+ onLoad() {
66
+ console.log(hello())
67
+ },
68
+ handleAction() {
69
+ ActionSheet.show({
70
+ theme: ActionSheetTheme.Grid,
71
+ selector: '#t-action-sheet',
72
+ context: this,
73
+ items: firstGrid,
74
+ align: 'center',
75
+ description: '',
76
+ })
77
+ },
78
+ })
@@ -0,0 +1,23 @@
1
+ <view class="min-h-screen {{ mode === 'light'?'bg-gray-100 text-slate-800':'bg-gray-900 text-slate-200' }} transition-colors duration-500">
2
+ <view class="flex flex-col items-center pt-20 space-y-10">
3
+ <view class="flex space-x-8">
4
+ <view class="w-24 h-24 bg-[url(https://vite.icebreaker.top/logo.png)] bg-[length:100%_100%] bg-no-repeat"></view>
5
+ <view class="w-32 h-24 bg-[url(https://vite.icebreaker.top/tw-logo.png)] bg-[length:100%_100%] bg-no-repeat"></view>
6
+ </view>
7
+ <view class="bg-gradient-to-r from-green-400 to-sky-400 bg-clip-text text-xl font-extrabold text-transparent underline">
8
+ weapp-vite & weapp-tailwindcss
9
+ </view>
10
+ <view class="{{ mode === 'light' ? 'i-mdi-moon-waxing-crescent':'i-mdi-weather-sunny text-white' }} text-8xl" bind:tap="switchMode"></view>
11
+ <view class="underline" mark:url="https://vite.icebreaker.top" bind:tap="copy">
12
+ https://vite.icebreaker.top
13
+ </view>
14
+ <view class="underline" mark:url="https://tw.icebreaker.top" bind:tap="copy">
15
+ https://tw.icebreaker.top
16
+ </view>
17
+ <view>
18
+ <t-button theme="primary" ghost @tap="handleAction">TDesign Button</t-button>
19
+ </view>
20
+ </view>
21
+ <t-action-sheet id="t-action-sheet" @selected="handleSelected" />
22
+ </view>
23
+
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/page.json",
3
+ "usingComponents": {
4
+ "navigation-bar": "/components/navigation-bar/navigation-bar"
5
+ }
6
+ }
File without changes
@@ -0,0 +1,3 @@
1
+ Component({
2
+
3
+ })
File without changes
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/sitemap.json",
3
+ "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
4
+ "rules": [
5
+ {
6
+ "action": "allow",
7
+ "page": "*"
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/theme.json",
3
+ "light": {},
4
+ "dark": {}
5
+ }
@@ -0,0 +1,3 @@
1
+ export function hello() {
2
+ return 'world'
3
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="weapp-vite/client" />
@@ -0,0 +1,22 @@
1
+ import type { Config } from 'tailwindcss'
2
+ import { getIconCollections, iconsPlugin } from '@egoist/tailwindcss-icons'
3
+
4
+ export default <Config>{
5
+ content: [
6
+ // 添加你需要提取的文件目录
7
+ 'src/**/*.{wxml,js,ts}',
8
+ ],
9
+ theme: {
10
+ extend: {},
11
+ },
12
+ plugins: [
13
+ iconsPlugin({
14
+ collections: getIconCollections(['mdi']),
15
+ }),
16
+ ],
17
+ corePlugins: {
18
+ // 小程序不需要 preflight 和 container,因为这主要是给 h5 的,如果你要同时开发小程序和 h5 端,你应该使用环境变量来控制它
19
+ preflight: false,
20
+ container: false,
21
+ },
22
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "jsx": "preserve",
5
+ "lib": [
6
+ "ES2020",
7
+ "DOM",
8
+ "DOM.Iterable"
9
+ ],
10
+ "useDefineForClassFields": true,
11
+ "baseUrl": ".",
12
+ "module": "ESNext",
13
+ "moduleResolution": "bundler",
14
+ "paths": {
15
+ "@/*": [
16
+ "./src/*"
17
+ ],
18
+ "tdesign-miniprogram/*": ["./node_modules/tdesign-miniprogram/miniprogram_dist/*"]
19
+ },
20
+ "resolveJsonModule": true,
21
+ "types": [
22
+ "miniprogram-api-typings"
23
+ ],
24
+ "allowImportingTsExtensions": true,
25
+ "allowJs": true,
26
+ "strict": true,
27
+ "noFallthroughCasesInSwitch": true,
28
+ "noUnusedLocals": true,
29
+ "noUnusedParameters": true,
30
+ "noEmit": true,
31
+ "isolatedModules": true,
32
+ "skipLibCheck": true
33
+ },
34
+ "references": [
35
+ {
36
+ "path": "./tsconfig.node.json"
37
+ }
38
+ ],
39
+ "include": [
40
+ "src/**/*.ts",
41
+ "src/**/*.js"
42
+ ],
43
+ "exclude": [
44
+ "node_modules",
45
+ "dist"
46
+ ]
47
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "allowSyntheticDefaultImports": true,
8
+ "skipLibCheck": true
9
+ },
10
+ "include": [
11
+ "vite.config.ts"
12
+ ]
13
+ }
@@ -0,0 +1,43 @@
1
+ import { UnifiedViteWeappTailwindcssPlugin } from 'weapp-tailwindcss/vite'
2
+ import { TDesignResolver } from 'weapp-vite/auto-import-components/resolvers'
3
+ import { defineConfig } from 'weapp-vite/config'
4
+
5
+ export default defineConfig({
6
+ weapp: {
7
+ srcRoot: 'src',
8
+ enhance: {
9
+ autoImportComponents: {
10
+ resolvers: [TDesignResolver()],
11
+ },
12
+ },
13
+ // pnpm g 生成的格式
14
+ // https://vite.icebreaker.top/guide/generate.html
15
+ generate: {
16
+ extensions: {
17
+ js: 'ts',
18
+ wxss: 'scss',
19
+ },
20
+ dirs: {
21
+ component: 'src/components',
22
+ page: 'src/pages',
23
+ },
24
+ // 假如你想让默认生成的组件命名为 HelloWorld/index 而不是 HelloWorld/HelloWorld 可以下列选项
25
+ // filenames: {
26
+ // component: 'index',
27
+ // page: 'index',
28
+ // },
29
+ },
30
+ },
31
+ css: {
32
+ preprocessorOptions: {
33
+ scss: {
34
+ silenceDeprecations: ['legacy-js-api', 'import'],
35
+ },
36
+ },
37
+ },
38
+ plugins: [
39
+ UnifiedViteWeappTailwindcssPlugin({
40
+ rem2rpx: true,
41
+ }),
42
+ ],
43
+ })
@@ -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,5 @@
1
+ {
2
+ "tailwindCSS.includeLanguages": {
3
+ "wxml": "html"
4
+ }
5
+ }
@@ -0,0 +1,28 @@
1
+ # weapp-vite-tailwindcss-vant-template
2
+
3
+ `weapp-vite` 集成 `tailwindcss`, `@vant/weapp` 的模板
4
+
5
+ ## 使用方式
6
+
7
+ ### 开发
8
+
9
+ - `pnpm dev`
10
+
11
+ - `pnpm dev --open` 可以打包并直接启动微信开发者工具
12
+
13
+ ### 构建
14
+
15
+ `pnpm build`
16
+
17
+ ### 打开微信开发者工具
18
+
19
+ `pnpm open`
20
+
21
+ ### 生成组件/页面
22
+
23
+ `pnpm g path/to/your/component`
24
+
25
+ ## 文档地址
26
+
27
+ 0. `weapp-vite`: https://vite.icebreaker.top/
28
+ 1. `weapp-tailwindcss`: https://tw.icebreaker.top/
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "weapp-vite-tailwindcss-vant-template",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "private": true,
6
+ "description": "原生微信小程序 weapp-vite + tailwindcss 模板",
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": "apps/weapp-vite-tailwindcss-vant-template"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/weapp-vite/weapp-vite/issues"
16
+ },
17
+ "keywords": [],
18
+ "scripts": {
19
+ "dev": "weapp-vite dev",
20
+ "dev:open": "weapp-vite dev -o",
21
+ "build": "weapp-vite build",
22
+ "open": "weapp-vite open",
23
+ "g": "weapp-vite generate",
24
+ "postinstall": "weapp-tw patch"
25
+ },
26
+ "devDependencies": {
27
+ "@egoist/tailwindcss-icons": "^1.8.1",
28
+ "@iconify-json/mdi": "^1.2.1",
29
+ "autoprefixer": "^10.4.20",
30
+ "miniprogram-api-typings": "^4.0.2",
31
+ "postcss": "^8.4.49",
32
+ "sass": "^1.83.0",
33
+ "tailwindcss": "^3.4.16",
34
+ "typescript": "^5.7.2",
35
+ "weapp-tailwindcss": "^3.7.0",
36
+ "weapp-vite": "workspace:*"
37
+ },
38
+ "dependencies": {
39
+ "@vant/weapp": "^1.11.7"
40
+ }
41
+ }
@@ -0,0 +1,6 @@
1
+ export default {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "description": "项目配置文件",
3
+ "miniprogramRoot": "dist/",
4
+ "compileType": "miniprogram",
5
+ "setting": {
6
+ "babelSetting": {
7
+ "ignore": [],
8
+ "disablePlugins": [],
9
+ "outputPath": ""
10
+ },
11
+ "coverView": false,
12
+ "postcss": false,
13
+ "minified": false,
14
+ "enhance": true,
15
+ "showShadowRootInWxmlPanel": false,
16
+ "packNpmRelationList": [
17
+ {
18
+ "packageJsonPath": "./package.json",
19
+ "miniprogramNpmDistDir": "./dist"
20
+ }
21
+ ],
22
+ "ignoreUploadUnusedFiles": true,
23
+ "compileHotReLoad": false,
24
+ "skylineRenderEnable": true,
25
+ "packNpmManually": true,
26
+ "es6": true
27
+ },
28
+ "simulatorType": "wechat",
29
+ "simulatorPluginLibVersion": {},
30
+ "condition": {},
31
+ "srcMiniprogramRoot": "dist/",
32
+ "editorSetting": {
33
+ "tabIndent": "insertSpaces",
34
+ "tabSize": 2
35
+ },
36
+ "libVersion": "2.32.3",
37
+ "packOptions": {
38
+ "ignore": [],
39
+ "include": []
40
+ },
41
+ "appid": "wx6ffee4673b257014"
42
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
3
+ "projectname": "weapp-vite-tailwindcss-template",
4
+ "setting": {
5
+ "compileHotReLoad": false
6
+ }
7
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/app.json",
3
+ "pages": [
4
+ "pages/index/index",
5
+ "pages/logs/logs"
6
+ ],
7
+ "window": {},
8
+ "componentFramework": "glass-easel",
9
+ "sitemapLocation": "sitemap.json",
10
+ "lazyCodeLoading": "requiredComponents"
11
+ }
@@ -0,0 +1,3 @@
1
+ @use 'tailwindcss/base';
2
+ @use 'tailwindcss/components';
3
+ @use 'tailwindcss/utilities';
@@ -0,0 +1,6 @@
1
+ App({
2
+ globalData: {},
3
+ onLaunch() {
4
+
5
+ },
6
+ })
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/component.json",
3
+ "component": true,
4
+ // 组件需要设置成 "apply-shared" 才能使用 app.wxss 里的全局样式
5
+ "styleIsolation": "apply-shared",
6
+ "usingComponents": {}
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/page.json",
3
+ "usingComponents": {
4
+ "navigation-bar": "/components/navigation-bar/navigation-bar"
5
+ },
6
+ "navigationBarTitleText": "初始模板"
7
+ }
File without changes
@@ -0,0 +1,39 @@
1
+ import { hello } from '@/utils/util'
2
+ import Dialog from '@vant/weapp/dialog/dialog'
3
+
4
+ Page({
5
+ data: {
6
+ mode: 'light',
7
+ },
8
+ switchMode() {
9
+ if (this.data.mode === 'light') {
10
+ this.setData({
11
+ mode: 'dark',
12
+ })
13
+ }
14
+ else {
15
+ this.setData({
16
+ mode: 'light',
17
+ })
18
+ }
19
+ },
20
+ async copy(e: WechatMiniprogram.BaseEvent) {
21
+ if (e.mark?.url) {
22
+ await wx.setClipboardData({
23
+ data: e.mark.url,
24
+ })
25
+ console.log(`复制成功: ${e.mark.url}`)
26
+ }
27
+ },
28
+ showDialog() {
29
+ Dialog.alert({
30
+ title: '我来自Vant',
31
+ message: '我是Dialog',
32
+ }).then(() => {
33
+ // on close
34
+ })
35
+ },
36
+ onLoad() {
37
+ console.log(hello())
38
+ },
39
+ })
@@ -0,0 +1,22 @@
1
+ <view class="min-h-screen {{ mode === 'light'?'bg-gray-100 text-slate-800':'bg-gray-900 text-slate-200' }} transition-colors duration-500">
2
+ <view class="flex flex-col items-center pt-20 space-y-10">
3
+ <view class="flex space-x-8">
4
+ <view class="w-24 h-24 bg-[url(https://vite.icebreaker.top/logo.png)] bg-[length:100%_100%] bg-no-repeat"></view>
5
+ <view class="w-32 h-24 bg-[url(https://vite.icebreaker.top/tw-logo.png)] bg-[length:100%_100%] bg-no-repeat"></view>
6
+ </view>
7
+ <view class="bg-gradient-to-r from-green-400 to-sky-400 bg-clip-text text-xl font-extrabold text-transparent underline">
8
+ weapp-vite & weapp-tailwindcss
9
+ </view>
10
+ <view class="{{ mode === 'light' ? 'i-mdi-moon-waxing-crescent':'i-mdi-weather-sunny text-white' }} text-8xl" bind:tap="switchMode"></view>
11
+ <view class="underline" mark:url="https://vite.icebreaker.top" bind:tap="copy">
12
+ https://vite.icebreaker.top
13
+ </view>
14
+ <view class="underline" mark:url="https://tw.icebreaker.top" bind:tap="copy">
15
+ https://tw.icebreaker.top
16
+ </view>
17
+ <view>
18
+ <van-button type="default" @tap="showDialog">Vant 按钮</van-button>
19
+ </view>
20
+ </view>
21
+ </view>
22
+ <van-dialog id="van-dialog" />
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/page.json",
3
+ "usingComponents": {
4
+ "navigation-bar": "/components/navigation-bar/navigation-bar"
5
+ }
6
+ }
File without changes
@@ -0,0 +1,3 @@
1
+ Component({
2
+
3
+ })
File without changes
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/sitemap.json",
3
+ "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
4
+ "rules": [
5
+ {
6
+ "action": "allow",
7
+ "page": "*"
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/theme.json",
3
+ "light": {},
4
+ "dark": {}
5
+ }
@@ -0,0 +1,3 @@
1
+ export function hello() {
2
+ return 'world'
3
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="weapp-vite/client" />
@@ -0,0 +1,22 @@
1
+ import type { Config } from 'tailwindcss'
2
+ import { getIconCollections, iconsPlugin } from '@egoist/tailwindcss-icons'
3
+
4
+ export default <Config>{
5
+ content: [
6
+ // 添加你需要提取的文件目录
7
+ 'src/**/*.{wxml,js,ts}',
8
+ ],
9
+ theme: {
10
+ extend: {},
11
+ },
12
+ plugins: [
13
+ iconsPlugin({
14
+ collections: getIconCollections(['mdi']),
15
+ }),
16
+ ],
17
+ corePlugins: {
18
+ // 小程序不需要 preflight 和 container,因为这主要是给 h5 的,如果你要同时开发小程序和 h5 端,你应该使用环境变量来控制它
19
+ preflight: false,
20
+ container: false,
21
+ },
22
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "jsx": "preserve",
5
+ "lib": [
6
+ "ES2020",
7
+ "DOM",
8
+ "DOM.Iterable"
9
+ ],
10
+ "useDefineForClassFields": true,
11
+ "baseUrl": ".",
12
+ "module": "ESNext",
13
+ "moduleResolution": "bundler",
14
+ "paths": {
15
+ "@/*": [
16
+ "./src/*"
17
+ ],
18
+ "@vant/weapp/*": [
19
+ "./node_modules/@vant/weapp/dist/*"
20
+ ]
21
+ },
22
+ "resolveJsonModule": true,
23
+ "types": [
24
+ "miniprogram-api-typings"
25
+ ],
26
+ "allowImportingTsExtensions": true,
27
+ "allowJs": true,
28
+ "strict": true,
29
+ "noFallthroughCasesInSwitch": true,
30
+ "noUnusedLocals": true,
31
+ "noUnusedParameters": true,
32
+ "noEmit": true,
33
+ "isolatedModules": true,
34
+ "skipLibCheck": true
35
+ },
36
+ "references": [
37
+ {
38
+ "path": "./tsconfig.node.json"
39
+ }
40
+ ],
41
+ "include": [
42
+ "src/**/*.ts",
43
+ "src/**/*.js"
44
+ ],
45
+ "exclude": [
46
+ "node_modules",
47
+ "dist"
48
+ ]
49
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "allowSyntheticDefaultImports": true,
8
+ "skipLibCheck": true
9
+ },
10
+ "include": [
11
+ "vite.config.ts"
12
+ ]
13
+ }
@@ -0,0 +1,43 @@
1
+ import { UnifiedViteWeappTailwindcssPlugin } from 'weapp-tailwindcss/vite'
2
+ import { VantResolver } from 'weapp-vite/auto-import-components/resolvers'
3
+ import { defineConfig } from 'weapp-vite/config'
4
+
5
+ export default defineConfig({
6
+ weapp: {
7
+ srcRoot: 'src',
8
+ enhance: {
9
+ autoImportComponents: {
10
+ resolvers: [VantResolver()],
11
+ },
12
+ },
13
+ // pnpm g 生成的格式
14
+ // https://vite.icebreaker.top/guide/generate.html
15
+ generate: {
16
+ extensions: {
17
+ js: 'ts',
18
+ wxss: 'scss',
19
+ },
20
+ dirs: {
21
+ component: 'src/components',
22
+ page: 'src/pages',
23
+ },
24
+ // 假如你想让默认生成的组件命名为 HelloWorld/index 而不是 HelloWorld/HelloWorld 可以下列选项
25
+ // filenames: {
26
+ // component: 'index',
27
+ // page: 'index',
28
+ // },
29
+ },
30
+ },
31
+ css: {
32
+ preprocessorOptions: {
33
+ scss: {
34
+ silenceDeprecations: ['legacy-js-api', 'import'],
35
+ },
36
+ },
37
+ },
38
+ plugins: [
39
+ UnifiedViteWeappTailwindcssPlugin({
40
+ rem2rpx: true,
41
+ }),
42
+ ],
43
+ })