create-uni-app-tailwindcss 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +23 -0
- package/dist/cli.js +150 -0
- package/dist/templates/default/.eslintrc-auto-import.json +115 -0
- package/dist/templates/default/README.md +140 -0
- package/dist/templates/default/_npmrc +8 -0
- package/dist/templates/default/eslint.config.mjs +27 -0
- package/dist/templates/default/index.html +24 -0
- package/dist/templates/default/package.json +105 -0
- package/dist/templates/default/scripts/app-css-smoke.mjs +69 -0
- package/dist/templates/default/scripts/hmr-smoke.mjs +252 -0
- package/dist/templates/default/src/App.vue +11 -0
- package/dist/templates/default/src/auto-imports.d.ts +109 -0
- package/dist/templates/default/src/components/WeappTailwindcss.vue +51 -0
- package/dist/templates/default/src/components/sections/CapabilityShowcase.vue +59 -0
- package/dist/templates/default/src/components/sections/ExperienceLab.vue +321 -0
- package/dist/templates/default/src/components/sections/GradientFeature.vue +128 -0
- package/dist/templates/default/src/components/sections/HeroShowcase.vue +14 -0
- package/dist/templates/default/src/components/sections/IconGallery.vue +58 -0
- package/dist/templates/default/src/components/sections/MacroShowcase.vue +156 -0
- package/dist/templates/default/src/env.d.ts +8 -0
- package/dist/templates/default/src/main.ts +13 -0
- package/dist/templates/default/src/manifest.json +56 -0
- package/dist/templates/default/src/pages/index/index.vue +49 -0
- package/dist/templates/default/src/pages.json +16 -0
- package/dist/templates/default/src/static/.gitkeep +0 -0
- package/dist/templates/default/src/static/images/weapp-tailwindcss.png +0 -0
- package/dist/templates/default/src/stores/counter.ts +11 -0
- package/dist/templates/default/src/tailwind.css +62 -0
- package/dist/templates/default/src/theme.json +10 -0
- package/dist/templates/default/src/uni.scss +0 -0
- package/dist/templates/default/stylelint.config.mjs +3 -0
- package/dist/templates/default/tsconfig.json +33 -0
- package/dist/templates/default/vite.config.ts +37 -0
- package/dist/templates/registry.json +25 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 ice breaker
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# create-uni-app-tailwindcss
|
|
2
|
+
|
|
3
|
+
Create a `uni-app + Vite + Vue 3 + Tailwind CSS` project.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pnpm create uni-app-tailwindcss my-app
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Select a template explicitly for CI or other non-interactive use:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm create uni-app-tailwindcss my-app --template default
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
When multiple templates are bundled and `--template` is omitted, the CLI prompts for one in interactive terminals and uses the registry default otherwise.
|
|
16
|
+
|
|
17
|
+
For local development in this monorepo:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm install
|
|
21
|
+
pnpm create
|
|
22
|
+
pnpm test:e2e
|
|
23
|
+
```
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli.ts
|
|
4
|
+
import { cp, mkdir, readFile, readdir, rm, writeFile } from "fs/promises";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import process from "process";
|
|
8
|
+
import prompts from "prompts";
|
|
9
|
+
var templatesRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "templates");
|
|
10
|
+
var options = parseArgs(process.argv.slice(2));
|
|
11
|
+
var targetArg = options.target;
|
|
12
|
+
var targetDir = path.resolve(process.cwd(), targetArg ?? "uni-app-tailwindcss-app");
|
|
13
|
+
var projectName = path.basename(targetDir);
|
|
14
|
+
async function main() {
|
|
15
|
+
const registry = await loadTemplateRegistry();
|
|
16
|
+
const template = await resolveTemplate(registry, options.template);
|
|
17
|
+
const packageManager = await resolvePackageManager(options.packageManager);
|
|
18
|
+
if (await exists(targetDir)) {
|
|
19
|
+
const result = await prompts({
|
|
20
|
+
type: "confirm",
|
|
21
|
+
name: "overwrite",
|
|
22
|
+
message: `Directory ${projectName} exists. Overwrite it?`,
|
|
23
|
+
initial: false
|
|
24
|
+
});
|
|
25
|
+
if (!result.overwrite) return;
|
|
26
|
+
await rm(targetDir, { recursive: true, force: true });
|
|
27
|
+
}
|
|
28
|
+
await mkdir(targetDir, { recursive: true });
|
|
29
|
+
await copyTemplate(path.join(templatesRoot, template.id), targetDir);
|
|
30
|
+
await renamePackage(targetDir, projectName);
|
|
31
|
+
console.log(`Created ${projectName}`);
|
|
32
|
+
console.log(`Template: ${template.id}`);
|
|
33
|
+
console.log(`cd ${projectName}`);
|
|
34
|
+
console.log(`${packageManager} install`);
|
|
35
|
+
console.log(`${packageManager} dev:h5`);
|
|
36
|
+
}
|
|
37
|
+
async function loadTemplateRegistry() {
|
|
38
|
+
return JSON.parse(await readFile(path.join(templatesRoot, "registry.json"), "utf8"));
|
|
39
|
+
}
|
|
40
|
+
async function copyTemplate(source, target) {
|
|
41
|
+
const entries = await readdir(source, { withFileTypes: true });
|
|
42
|
+
for (const entry of entries) {
|
|
43
|
+
const sourcePath = path.join(source, entry.name);
|
|
44
|
+
const targetName = entry.name === "_npmrc" ? ".npmrc" : entry.name;
|
|
45
|
+
const targetPath = path.join(target, targetName);
|
|
46
|
+
if (entry.isDirectory()) {
|
|
47
|
+
await mkdir(targetPath, { recursive: true });
|
|
48
|
+
await copyTemplate(sourcePath, targetPath);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
await cp(sourcePath, targetPath);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function renamePackage(targetDir2, name) {
|
|
55
|
+
const pkgPath = path.join(targetDir2, "package.json");
|
|
56
|
+
const pkg = JSON.parse(await readFile(pkgPath, "utf8"));
|
|
57
|
+
pkg.name = name;
|
|
58
|
+
await writeFile(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
59
|
+
`);
|
|
60
|
+
}
|
|
61
|
+
async function exists(filePath) {
|
|
62
|
+
try {
|
|
63
|
+
await readdir(filePath);
|
|
64
|
+
return true;
|
|
65
|
+
} catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function parseArgs(args) {
|
|
70
|
+
let packageManager;
|
|
71
|
+
let template;
|
|
72
|
+
let target;
|
|
73
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
74
|
+
const arg = args[index];
|
|
75
|
+
if (arg === "--") {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (arg === "--pm" || arg === "--package-manager") {
|
|
79
|
+
packageManager = args[index + 1];
|
|
80
|
+
index += 1;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (arg.startsWith("--pm=")) {
|
|
84
|
+
packageManager = arg.slice("--pm=".length);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (arg.startsWith("--package-manager=")) {
|
|
88
|
+
packageManager = arg.slice("--package-manager=".length);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (arg === "--template") {
|
|
92
|
+
template = args[index + 1];
|
|
93
|
+
index += 1;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (arg.startsWith("--template=")) {
|
|
97
|
+
template = arg.slice("--template=".length);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (!arg.startsWith("-") && !target) {
|
|
101
|
+
target = arg;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return { packageManager, target, template };
|
|
105
|
+
}
|
|
106
|
+
async function resolveTemplate(registry, templateId) {
|
|
107
|
+
if (templateId) {
|
|
108
|
+
const template = registry.templates.find((item) => item.id === templateId);
|
|
109
|
+
if (!template) {
|
|
110
|
+
throw new Error(`Unknown template "${templateId}". Available templates: ${registry.templates.map((item) => item.id).join(", ")}`);
|
|
111
|
+
}
|
|
112
|
+
return template;
|
|
113
|
+
}
|
|
114
|
+
if (!process.stdin.isTTY || registry.templates.length === 1) {
|
|
115
|
+
return registry.templates.find((item) => item.id === registry.defaultTemplate) ?? registry.templates[0];
|
|
116
|
+
}
|
|
117
|
+
const response = await prompts({
|
|
118
|
+
type: "select",
|
|
119
|
+
name: "template",
|
|
120
|
+
message: "Template",
|
|
121
|
+
choices: registry.templates.map((template) => ({
|
|
122
|
+
description: template.description,
|
|
123
|
+
title: template.name,
|
|
124
|
+
value: template.id
|
|
125
|
+
})),
|
|
126
|
+
initial: Math.max(0, registry.templates.findIndex((item) => item.id === registry.defaultTemplate))
|
|
127
|
+
});
|
|
128
|
+
return registry.templates.find((item) => item.id === response.template) ?? registry.templates.find((item) => item.id === registry.defaultTemplate) ?? registry.templates[0];
|
|
129
|
+
}
|
|
130
|
+
async function resolvePackageManager(packageManager) {
|
|
131
|
+
const managers = ["pnpm", "npm", "yarn", "bun"];
|
|
132
|
+
if (packageManager && managers.includes(packageManager)) {
|
|
133
|
+
return packageManager;
|
|
134
|
+
}
|
|
135
|
+
if (!process.stdin.isTTY) {
|
|
136
|
+
return "pnpm";
|
|
137
|
+
}
|
|
138
|
+
const response = await prompts({
|
|
139
|
+
type: "select",
|
|
140
|
+
name: "packageManager",
|
|
141
|
+
message: "Package manager",
|
|
142
|
+
choices: managers.map((manager) => ({ title: manager, value: manager })),
|
|
143
|
+
initial: 0
|
|
144
|
+
});
|
|
145
|
+
return response.packageManager ?? "pnpm";
|
|
146
|
+
}
|
|
147
|
+
main().catch((error) => {
|
|
148
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
149
|
+
process.exitCode = 1;
|
|
150
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
{
|
|
2
|
+
"globals": {
|
|
3
|
+
"Component": true,
|
|
4
|
+
"ComponentPublicInstance": true,
|
|
5
|
+
"ComputedRef": true,
|
|
6
|
+
"DirectiveBinding": true,
|
|
7
|
+
"EffectScope": true,
|
|
8
|
+
"ExtractDefaultPropTypes": true,
|
|
9
|
+
"ExtractPropTypes": true,
|
|
10
|
+
"ExtractPublicPropTypes": true,
|
|
11
|
+
"InjectionKey": true,
|
|
12
|
+
"MaybeRef": true,
|
|
13
|
+
"MaybeRefOrGetter": true,
|
|
14
|
+
"PropType": true,
|
|
15
|
+
"Ref": true,
|
|
16
|
+
"ShallowRef": true,
|
|
17
|
+
"Slot": true,
|
|
18
|
+
"Slots": true,
|
|
19
|
+
"VNode": true,
|
|
20
|
+
"WritableComputedRef": true,
|
|
21
|
+
"acceptHMRUpdate": true,
|
|
22
|
+
"computed": true,
|
|
23
|
+
"createApp": true,
|
|
24
|
+
"createPinia": true,
|
|
25
|
+
"customRef": true,
|
|
26
|
+
"defineAsyncComponent": true,
|
|
27
|
+
"defineComponent": true,
|
|
28
|
+
"defineStore": true,
|
|
29
|
+
"effectScope": true,
|
|
30
|
+
"getActivePinia": true,
|
|
31
|
+
"getCurrentInstance": true,
|
|
32
|
+
"getCurrentScope": true,
|
|
33
|
+
"getCurrentWatcher": true,
|
|
34
|
+
"h": true,
|
|
35
|
+
"inject": true,
|
|
36
|
+
"isProxy": true,
|
|
37
|
+
"isReactive": true,
|
|
38
|
+
"isReadonly": true,
|
|
39
|
+
"isRef": true,
|
|
40
|
+
"isShallow": true,
|
|
41
|
+
"mapActions": true,
|
|
42
|
+
"mapGetters": true,
|
|
43
|
+
"mapState": true,
|
|
44
|
+
"mapStores": true,
|
|
45
|
+
"mapWritableState": true,
|
|
46
|
+
"markRaw": true,
|
|
47
|
+
"nextTick": true,
|
|
48
|
+
"onActivated": true,
|
|
49
|
+
"onAddToFavorites": true,
|
|
50
|
+
"onBackPress": true,
|
|
51
|
+
"onBeforeMount": true,
|
|
52
|
+
"onBeforeUnmount": true,
|
|
53
|
+
"onBeforeUpdate": true,
|
|
54
|
+
"onDeactivated": true,
|
|
55
|
+
"onError": true,
|
|
56
|
+
"onErrorCaptured": true,
|
|
57
|
+
"onHide": true,
|
|
58
|
+
"onLaunch": true,
|
|
59
|
+
"onLoad": true,
|
|
60
|
+
"onMounted": true,
|
|
61
|
+
"onNavigationBarButtonTap": true,
|
|
62
|
+
"onNavigationBarSearchInputChanged": true,
|
|
63
|
+
"onNavigationBarSearchInputClicked": true,
|
|
64
|
+
"onNavigationBarSearchInputConfirmed": true,
|
|
65
|
+
"onNavigationBarSearchInputFocusChanged": true,
|
|
66
|
+
"onPageNotFound": true,
|
|
67
|
+
"onPageScroll": true,
|
|
68
|
+
"onPullDownRefresh": true,
|
|
69
|
+
"onReachBottom": true,
|
|
70
|
+
"onReady": true,
|
|
71
|
+
"onRenderTracked": true,
|
|
72
|
+
"onRenderTriggered": true,
|
|
73
|
+
"onResize": true,
|
|
74
|
+
"onScopeDispose": true,
|
|
75
|
+
"onServerPrefetch": true,
|
|
76
|
+
"onShareAppMessage": true,
|
|
77
|
+
"onShareTimeline": true,
|
|
78
|
+
"onShow": true,
|
|
79
|
+
"onTabItemTap": true,
|
|
80
|
+
"onThemeChange": true,
|
|
81
|
+
"onUnhandledRejection": true,
|
|
82
|
+
"onUnload": true,
|
|
83
|
+
"onUnmounted": true,
|
|
84
|
+
"onUpdated": true,
|
|
85
|
+
"onWatcherCleanup": true,
|
|
86
|
+
"provide": true,
|
|
87
|
+
"reactive": true,
|
|
88
|
+
"readonly": true,
|
|
89
|
+
"ref": true,
|
|
90
|
+
"resolveComponent": true,
|
|
91
|
+
"setActivePinia": true,
|
|
92
|
+
"setMapStoreSuffix": true,
|
|
93
|
+
"shallowReactive": true,
|
|
94
|
+
"shallowReadonly": true,
|
|
95
|
+
"shallowRef": true,
|
|
96
|
+
"storeToRefs": true,
|
|
97
|
+
"toRaw": true,
|
|
98
|
+
"toRef": true,
|
|
99
|
+
"toRefs": true,
|
|
100
|
+
"toValue": true,
|
|
101
|
+
"triggerRef": true,
|
|
102
|
+
"unref": true,
|
|
103
|
+
"useAttrs": true,
|
|
104
|
+
"useCssModule": true,
|
|
105
|
+
"useCssVars": true,
|
|
106
|
+
"useId": true,
|
|
107
|
+
"useModel": true,
|
|
108
|
+
"useSlots": true,
|
|
109
|
+
"useTemplateRef": true,
|
|
110
|
+
"watch": true,
|
|
111
|
+
"watchEffect": true,
|
|
112
|
+
"watchPostEffect": true,
|
|
113
|
+
"watchSyncEffect": true
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# uni-app-tailwindcss-template
|
|
2
|
+
|
|
3
|
+
`uni-app + Vite + Vue 3 + Tailwind CSS` 的 VS Code 多端模板。
|
|
4
|
+
|
|
5
|
+
## 适用场景
|
|
6
|
+
|
|
7
|
+
- 使用 `uni-app` 的 `Vite` 方案开发多端项目
|
|
8
|
+
- 同时运行到微信小程序、H5、Android 和 iOS
|
|
9
|
+
- 需要 `Vue 3`、Pinia、自动导入和 `weapp-tailwindcss` 集成
|
|
10
|
+
|
|
11
|
+
## 技术栈
|
|
12
|
+
|
|
13
|
+
- `uni-app`
|
|
14
|
+
- `Vite`
|
|
15
|
+
- `Vue 3`
|
|
16
|
+
- `Tailwind CSS v4`
|
|
17
|
+
- `weapp-tailwindcss`
|
|
18
|
+
- `pnpm`
|
|
19
|
+
|
|
20
|
+
> 当前主分支是 `tailwindcss@4` 版本;如果需要 `tailwindcss@3` 版本,请切换到 `tailwindcss@3` 分支。
|
|
21
|
+
|
|
22
|
+
## 支持平台
|
|
23
|
+
|
|
24
|
+
| 平台 | 开发命令 | 生产构建 |
|
|
25
|
+
| ---------- | ------------------------- | ---------------------- |
|
|
26
|
+
| 微信小程序 | `pnpm dev:mp-weixin` | `pnpm build:mp-weixin` |
|
|
27
|
+
| H5 | `pnpm dev:h5` | `pnpm build:h5` |
|
|
28
|
+
| Android | `pnpm launch:app:android` | `pnpm build:app` |
|
|
29
|
+
| iOS 模拟器 | `pnpm launch:app:ios` | `pnpm build:app` |
|
|
30
|
+
|
|
31
|
+
`build:app` 生成 Android 和 iOS 共用的 `app-plus` WebView 资源,不会生成已签名的 APK 或 IPA。
|
|
32
|
+
|
|
33
|
+
## 使用前提
|
|
34
|
+
|
|
35
|
+
- Node.js `22+`
|
|
36
|
+
- `pnpm`
|
|
37
|
+
- 微信开发者工具,用于微信小程序
|
|
38
|
+
- HBuilderX `5.0+`,用于 Android 和 iOS App 调试
|
|
39
|
+
- Android SDK、模拟器或已开启调试的 Android 设备
|
|
40
|
+
- macOS、Xcode 和 iOS 模拟器,或已配置开发证书的 iOS 真机
|
|
41
|
+
|
|
42
|
+
发布 App 前,还需要在 `src/manifest.json` 中配置自己的 DCloud AppID、Android 包名与签名,或 iOS Bundle ID 与证书。模板不保存任何发布证书。
|
|
43
|
+
|
|
44
|
+
## 快速开始
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pnpm install
|
|
48
|
+
pnpm dev:mp-weixin
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`weapp-tailwindcss@5` 会在构建运行时完成 Tailwind CSS 生成和类名收集,安装依赖时无需额外的 Tailwind 补丁或构建脚本授权。
|
|
52
|
+
|
|
53
|
+
如果需要直接打开微信开发者工具:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pnpm open:dev
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 运行 Android 和 iOS
|
|
60
|
+
|
|
61
|
+
HBuilderX 5 提供 App CLI 启动能力。请尽量让 HBuilderX、标准调试基座与项目使用的 uni-app 编译器保持同一版本,避免运行时与编译产物不兼容。先启动 Android 模拟器、连接 Android 设备或启动 iOS 模拟器,再执行:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pnpm launch:app:android
|
|
65
|
+
pnpm launch:app:ios
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
指定设备时,把 HBuilderX 设备列表中的 ID 透传给命令:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pnpm launch:app:android --deviceId <android-device-id>
|
|
72
|
+
pnpm launch:app:ios --deviceId <ios-simulator-uuid>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`launch:app:ios` 默认运行到 iOS 模拟器。真机运行需要在 HBuilderX 中配置 Apple 开发证书与描述文件。
|
|
76
|
+
|
|
77
|
+
也可以使用传统的编译监听流程:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pnpm dev:app
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
编译完成后,在 HBuilderX 中导入 `dist/dev/app`,再选择“运行到手机或模拟器”。生产 App 资源位于 `dist/build/app`:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pnpm build:app
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## 常用命令
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
pnpm dev:mp-weixin
|
|
93
|
+
pnpm build:mp-weixin
|
|
94
|
+
pnpm dev:h5
|
|
95
|
+
pnpm build:h5
|
|
96
|
+
pnpm dev:app
|
|
97
|
+
pnpm build:app
|
|
98
|
+
pnpm launch:app:android
|
|
99
|
+
pnpm launch:app:ios
|
|
100
|
+
pnpm test:app-css
|
|
101
|
+
pnpm open:dev
|
|
102
|
+
pnpm open:build
|
|
103
|
+
pnpm lint
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## 跨端样式约定
|
|
107
|
+
|
|
108
|
+
- 布局优先使用可被 Tailwind 扫描到的静态 class,运行时样式 class 使用枚举值,不自由拼接字符串。
|
|
109
|
+
- Tailwind 间距和断点在相同逻辑宽度下保持一致;需要随屏幕缩放的尺寸可以使用 `rpx` 任意值。
|
|
110
|
+
- 页面内容容器共用同一组宽度、间距和断点。Android 与 iOS 的系统状态栏、原生导航栏和字体抗锯齿允许存在平台差异。
|
|
111
|
+
- 页面底部包含安全区留白,避免 iOS Home Indicator 和 Android 手势导航栏遮挡内容。
|
|
112
|
+
- 图片优先放在 `src/static` 并使用 uni-app `image` 组件,避免不同平台的网络和加载时序造成布局偏移。
|
|
113
|
+
- 小程序专用样式使用 `wx:`,其他宿主使用 `not-wx:`;Android 与 iOS 都进入同一个 `not-wx` 分支。
|
|
114
|
+
|
|
115
|
+
## 模板说明
|
|
116
|
+
|
|
117
|
+
- Tailwind CSS 由 `weapp-tailwindcss@5` 在构建运行时生成,无需安装后补丁
|
|
118
|
+
- App WebView 兼容由 `weapp-tailwindcss` 内置的 `legacy-web` 处理链提供;模板不再维护额外的 PostCSS 兼容插件,并保留 Tailwind CSS v4 的运行时 `--spacing` 语义
|
|
119
|
+
- `pnpm test:app-css` 会构建 App 资源,并回归检查间距变量、`space-y` 反转公式、渐变文字 WebKit 前缀和 Android/iOS 平台声明
|
|
120
|
+
- 样式条件编译示例使用 `@custom-variant wx` / `@custom-variant not-wx`
|
|
121
|
+
- 请先把 `src/manifest.json` 中的 AppID 替换成自己的配置
|
|
122
|
+
- 模板内保留了 `up:pkg` 和 `up:uniapp`,用于分别升级通用依赖和 `uni-app` 依赖
|
|
123
|
+
- 推荐在 VS Code 中安装 `Tailwind CSS IntelliSense`、ESLint、Stylelint
|
|
124
|
+
- GitHub Actions 会构建 H5、App 和主要小程序目标,但不会执行 App 签名或模拟器启动
|
|
125
|
+
|
|
126
|
+
## 项目级技能
|
|
127
|
+
|
|
128
|
+
仓库已内置项目级 `uni-app` skill,供 Codex 等 agent 在当前项目内直接复用:
|
|
129
|
+
|
|
130
|
+
- 技能目录:`.agents/skills/uni-app`
|
|
131
|
+
- 锁文件:`skills-lock.json`
|
|
132
|
+
- 技能入口:`.agents/skills/uni-app/SKILL.md`
|
|
133
|
+
|
|
134
|
+
这个仓库只保留最小集合,不提交 `.claude/`、`.continue/`、`skills/` 这类兼容性符号链接目录。
|
|
135
|
+
|
|
136
|
+
## 相关文档
|
|
137
|
+
|
|
138
|
+
- `weapp-tailwindcss`:<https://tw.icebreaker.top/>
|
|
139
|
+
- `uni-app`:<https://uniapp.dcloud.net.cn/>
|
|
140
|
+
- HBuilderX App CLI:<https://hx.dcloud.net.cn/cli/launch-app>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { icebreaker } from '@icebreakers/eslint-config'
|
|
2
|
+
|
|
3
|
+
export default icebreaker(
|
|
4
|
+
{
|
|
5
|
+
vue: true,
|
|
6
|
+
betterTailwindcss: {
|
|
7
|
+
entryPoint: './src/tailwind.css',
|
|
8
|
+
},
|
|
9
|
+
weapp: true,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
ignores: [
|
|
13
|
+
'.agents/**',
|
|
14
|
+
'.claude/**',
|
|
15
|
+
'.continue/**',
|
|
16
|
+
'skills/**',
|
|
17
|
+
],
|
|
18
|
+
// 规则可以在这里禁用
|
|
19
|
+
rules: {
|
|
20
|
+
'better-tailwindcss/enforce-canonical-classes': 'off',
|
|
21
|
+
'better-tailwindcss/enforce-consistent-class-order': 'off',
|
|
22
|
+
'better-tailwindcss/enforce-consistent-line-wrapping': 'off',
|
|
23
|
+
'better-tailwindcss/no-conflicting-classes': 'off',
|
|
24
|
+
'better-tailwindcss/no-unknown-classes': 'off',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<script>
|
|
6
|
+
var coverSupport =
|
|
7
|
+
'CSS' in window &&
|
|
8
|
+
typeof CSS.supports === 'function' &&
|
|
9
|
+
(CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
|
|
10
|
+
document.write(
|
|
11
|
+
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
|
|
12
|
+
(coverSupport ? ', viewport-fit=cover' : '') +
|
|
13
|
+
'" />',
|
|
14
|
+
)
|
|
15
|
+
</script>
|
|
16
|
+
<title></title>
|
|
17
|
+
<!--preload-links-->
|
|
18
|
+
<!--app-context-->
|
|
19
|
+
</head>
|
|
20
|
+
<body>
|
|
21
|
+
<div id="app"><!--app-html--></div>
|
|
22
|
+
<script type="module" src="/src/main.ts"></script>
|
|
23
|
+
</body>
|
|
24
|
+
</html>
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "uni-app-tailwindcss-template-default",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"packageManager": "pnpm@11.21.0",
|
|
6
|
+
"imports": {
|
|
7
|
+
"#tailwind.css": "./src/tailwind.css"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "uni -p mp-weixin",
|
|
11
|
+
"build": "pnpm build:mp-weixin",
|
|
12
|
+
"dev:app": "uni -p app",
|
|
13
|
+
"launch:app:android": "uni-launch app-android",
|
|
14
|
+
"launch:app:ios": "uni-launch app-ios --iosTarget simulator",
|
|
15
|
+
"dev:custom": "uni -p",
|
|
16
|
+
"dev:h5": "uni --host",
|
|
17
|
+
"dev:h5:ssr": "uni --ssr",
|
|
18
|
+
"dev:mp-alipay": "uni -p mp-alipay",
|
|
19
|
+
"dev:mp-baidu": "uni -p mp-baidu",
|
|
20
|
+
"dev:mp-kuaishou": "uni -p mp-kuaishou",
|
|
21
|
+
"dev:mp-lark": "uni -p mp-lark",
|
|
22
|
+
"dev:mp-qq": "uni -p mp-qq",
|
|
23
|
+
"dev:mp-toutiao": "uni -p mp-toutiao",
|
|
24
|
+
"dev:mp-weixin": "uni -p mp-weixin",
|
|
25
|
+
"dev:quickapp-webview": "uni -p quickapp-webview",
|
|
26
|
+
"dev:quickapp-webview-huawei": "uni -p quickapp-webview-huawei",
|
|
27
|
+
"dev:quickapp-webview-union": "uni -p quickapp-webview-union",
|
|
28
|
+
"build:app": "uni build -p app",
|
|
29
|
+
"build:custom": "uni build -p",
|
|
30
|
+
"build:h5": "uni build",
|
|
31
|
+
"build:h5:ssr": "uni build --ssr",
|
|
32
|
+
"build:mp-alipay": "uni build -p mp-alipay",
|
|
33
|
+
"build:mp-baidu": "uni build -p mp-baidu",
|
|
34
|
+
"build:mp-kuaishou": "uni build -p mp-kuaishou",
|
|
35
|
+
"build:mp-lark": "uni build -p mp-lark",
|
|
36
|
+
"build:mp-qq": "uni build -p mp-qq",
|
|
37
|
+
"build:mp-toutiao": "uni build -p mp-toutiao",
|
|
38
|
+
"build:mp-weixin": "uni build -p mp-weixin",
|
|
39
|
+
"build:quickapp-webview": "uni build -p quickapp-webview",
|
|
40
|
+
"build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",
|
|
41
|
+
"build:quickapp-webview-union": "uni build -p quickapp-webview-union",
|
|
42
|
+
"open:dev": "weapp open -p dist/dev/mp-weixin",
|
|
43
|
+
"open:build": "weapp open -p dist/build/mp-weixin",
|
|
44
|
+
"weapp:login": "weapp login",
|
|
45
|
+
"upload:dev": "weapp upload -p dist/dev/mp-weixin -v 1.0.0 -d \"dev version\"",
|
|
46
|
+
"upload:build": "weapp upload -p dist/build/mp-weixin -v 1.0.0 -d \"release version\"",
|
|
47
|
+
"test:hmr": "node scripts/hmr-smoke.mjs",
|
|
48
|
+
"test:hmr:mp-weixin": "pnpm run test:hmr -- --platform mp-weixin --script dev:mp-weixin",
|
|
49
|
+
"test:app-css": "pnpm build:app && node scripts/app-css-smoke.mjs",
|
|
50
|
+
"lint": "eslint .",
|
|
51
|
+
"lint:fix": "eslint ./src --fix",
|
|
52
|
+
"up:pkg": "pnpm up -rLi \"!@dcloudio/*\"",
|
|
53
|
+
"up:uniapp": "pnpx @dcloudio/uvm@latest"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@dcloudio/uni-app": "3.0.0-5020320260806002",
|
|
57
|
+
"@dcloudio/uni-app-harmony": "3.0.0-5020320260806002",
|
|
58
|
+
"@dcloudio/uni-app-plus": "3.0.0-5020320260806002",
|
|
59
|
+
"@dcloudio/uni-components": "3.0.0-5020320260806002",
|
|
60
|
+
"@dcloudio/uni-h5": "3.0.0-5020320260806002",
|
|
61
|
+
"@dcloudio/uni-mp-alipay": "3.0.0-5020320260806002",
|
|
62
|
+
"@dcloudio/uni-mp-baidu": "3.0.0-5020320260806002",
|
|
63
|
+
"@dcloudio/uni-mp-harmony": "3.0.0-5020320260806002",
|
|
64
|
+
"@dcloudio/uni-mp-jd": "3.0.0-5020320260806002",
|
|
65
|
+
"@dcloudio/uni-mp-kuaishou": "3.0.0-5020320260806002",
|
|
66
|
+
"@dcloudio/uni-mp-lark": "3.0.0-5020320260806002",
|
|
67
|
+
"@dcloudio/uni-mp-qq": "3.0.0-5020320260806002",
|
|
68
|
+
"@dcloudio/uni-mp-toutiao": "3.0.0-5020320260806002",
|
|
69
|
+
"@dcloudio/uni-mp-weixin": "3.0.0-5020320260806002",
|
|
70
|
+
"@dcloudio/uni-mp-xhs": "3.0.0-5020320260806002",
|
|
71
|
+
"@dcloudio/uni-quickapp-webview": "3.0.0-5020320260806002",
|
|
72
|
+
"@vue/shared": "3.4.21",
|
|
73
|
+
"@weapp-tailwindcss/merge": "^2.2.1",
|
|
74
|
+
"pinia": "2.2.4",
|
|
75
|
+
"vue": "^3.4.21",
|
|
76
|
+
"vue-i18n": "^9.1.9"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@dcloudio/hbuilderx-cli": "^1.2.0",
|
|
80
|
+
"@dcloudio/types": "^3.4.8",
|
|
81
|
+
"@dcloudio/uni-automator": "3.0.0-5020320260806002",
|
|
82
|
+
"@dcloudio/uni-cli-shared": "3.0.0-5020320260806002",
|
|
83
|
+
"@dcloudio/uni-stacktracey": "3.0.0-5020320260806002",
|
|
84
|
+
"@dcloudio/vite-plugin-uni": "3.0.0-5020320260806002",
|
|
85
|
+
"@icebreakers/eslint-config": "^7.0.2",
|
|
86
|
+
"@icebreakers/stylelint-config": "^5.0.3",
|
|
87
|
+
"@iconify-json/mdi": "^1.2.3",
|
|
88
|
+
"@iconify-json/svg-spinners": "^1.2.4",
|
|
89
|
+
"@iconify/tailwind4": "^1.2.3",
|
|
90
|
+
"@types/node": "^26.2.0",
|
|
91
|
+
"@vue/runtime-core": "^3.4.21",
|
|
92
|
+
"autoprefixer": "^10.5.4",
|
|
93
|
+
"eslint": "^10.8.1",
|
|
94
|
+
"postcss": "^8.5.26",
|
|
95
|
+
"rollup": "4.14.3",
|
|
96
|
+
"sass": "^1.102.0",
|
|
97
|
+
"stylelint": "^17.14.1",
|
|
98
|
+
"tailwindcss": "^4.3.3",
|
|
99
|
+
"typescript": "^6.0.3",
|
|
100
|
+
"unplugin-auto-import": "^20.3.0",
|
|
101
|
+
"vite": "5.2.8",
|
|
102
|
+
"weapp-ide-cli": "^6.0.5",
|
|
103
|
+
"weapp-tailwindcss": "^5.2.14"
|
|
104
|
+
}
|
|
105
|
+
}
|