mirror of
https://gitee.com/vant-contrib/vant.git
synced 2026-01-02 13:26:57 +08:00
Compare commits
477 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b45b0b7608 | ||
|
|
c309ca2aaf | ||
|
|
66df033ec8 | ||
|
|
e2ea3be819 | ||
|
|
019c328975 | ||
|
|
0e55b72200 | ||
|
|
69d3ba000c | ||
|
|
9418fe371d | ||
|
|
5d8282ddae | ||
|
|
43ff890d79 | ||
|
|
98642589ee | ||
|
|
6f910c9913 | ||
|
|
1b08f84ac6 | ||
|
|
f0d3e04fba | ||
|
|
830a1eb5cf | ||
|
|
cd439c04f3 | ||
|
|
0aac165d4e | ||
|
|
f60a3b840d | ||
|
|
997f3e0acd | ||
|
|
e2fe50250c | ||
|
|
bc024a105c | ||
|
|
7afb74345a | ||
|
|
65fdb2155b | ||
|
|
c6bc97f4e4 | ||
|
|
7d023fd6e4 | ||
|
|
1afe960f30 | ||
|
|
3e039b02b5 | ||
|
|
1837ed712f | ||
|
|
94c5afe65c | ||
|
|
5174a1a668 | ||
|
|
ed8cd77449 | ||
|
|
a677bee2b8 | ||
|
|
05544c109f | ||
|
|
21c57caa9b | ||
|
|
66aa2906e0 | ||
|
|
61ef6b9a98 | ||
|
|
c25acb8d46 | ||
|
|
8bcb34724f | ||
|
|
cf5e7e6629 | ||
|
|
a02cfe9604 | ||
|
|
71354f7742 | ||
|
|
84b05f0668 | ||
|
|
95542bf06e | ||
|
|
8d15fa4fdf | ||
|
|
35f81fb208 | ||
|
|
da3400435f | ||
|
|
50ee584953 | ||
|
|
889b28609a | ||
|
|
6a7376d15d | ||
|
|
2cca630808 | ||
|
|
dcffa09812 | ||
|
|
0881de82af | ||
|
|
86adc66dd9 | ||
|
|
1d87343195 | ||
|
|
aa1689fed8 | ||
|
|
b6dd0cb36c | ||
|
|
4b2e06b34d | ||
|
|
717f244d2f | ||
|
|
6b7ae0f6a0 | ||
|
|
cb93bd2da3 | ||
|
|
ca583e1075 | ||
|
|
667034322e | ||
|
|
8d51f9e08e | ||
|
|
236a2e43f3 | ||
|
|
326880a4e1 | ||
|
|
31ac5faa3a | ||
|
|
1e8187bc37 | ||
|
|
72d515b30e | ||
|
|
b4072ef2bd | ||
|
|
ec1d32db4a | ||
|
|
dfdc27a755 | ||
|
|
8574339579 | ||
|
|
5c6992f97c | ||
|
|
292ac6b55e | ||
|
|
1945c35b17 | ||
|
|
da3ad139d4 | ||
|
|
3aca130ca5 | ||
|
|
f060d1a813 | ||
|
|
041039b5e9 | ||
|
|
68b93a4008 | ||
|
|
4e83e5ecc0 | ||
|
|
8ef197ea12 | ||
|
|
dc0a29be17 | ||
|
|
a06f1567db | ||
|
|
e17cc35dcf | ||
|
|
04494a450d | ||
|
|
e5cc32ca97 | ||
|
|
c3776877ca | ||
|
|
f61b00175e | ||
|
|
6a1516ca37 | ||
|
|
7eaefd04fa | ||
|
|
ed5ea225ca | ||
|
|
b117e21dc4 | ||
|
|
961f70d523 | ||
|
|
cfdb5c1fbe | ||
|
|
89718934af | ||
|
|
6fee5cfed8 | ||
|
|
9e8a0864c3 | ||
|
|
c3a8275ebf | ||
|
|
c88b034aac | ||
|
|
d96c4228f5 | ||
|
|
41d6b5191d | ||
|
|
d3c679aa27 | ||
|
|
e6b43db90b | ||
|
|
2f6ef7aed8 | ||
|
|
729e283ab5 | ||
|
|
a1d4297c92 | ||
|
|
e45ac25ac0 | ||
|
|
83a4e286bd | ||
|
|
f4ab1b8c0c | ||
|
|
7879fd6395 | ||
|
|
11dbde14f6 | ||
|
|
537e629d7d | ||
|
|
178df39c44 | ||
|
|
74c1c2927e | ||
|
|
a31f78b07a | ||
|
|
794fd029a0 | ||
|
|
c628a66770 | ||
|
|
b6c8d3f39f | ||
|
|
627661e0ed | ||
|
|
11d25a0b0e | ||
|
|
b46b429682 | ||
|
|
15142770f2 | ||
|
|
aea97f90e6 | ||
|
|
abce9fdafd | ||
|
|
1050ab33f5 | ||
|
|
a0bd47dd84 | ||
|
|
1ac1bb94e7 | ||
|
|
53162941da | ||
|
|
e998c1be95 | ||
|
|
a53dc02b0a | ||
|
|
1ce400bb7f | ||
|
|
5a3fe7ed0f | ||
|
|
1bc6cbdb69 | ||
|
|
5179891faa | ||
|
|
ba95cad78d | ||
|
|
9a6bc32cf4 | ||
|
|
419a8e4f0e | ||
|
|
d712da5778 | ||
|
|
5f526c9f0e | ||
|
|
ec78d5b1d9 | ||
|
|
e5e6e8aaa4 | ||
|
|
e27efdad0d | ||
|
|
beeb059401 | ||
|
|
5883d3e0c7 | ||
|
|
2e27c67c76 | ||
|
|
28e8b72ccd | ||
|
|
8256fdc927 | ||
|
|
e60f36390a | ||
|
|
0a8420fdac | ||
|
|
eea5f002a7 | ||
|
|
2f1066e9c6 | ||
|
|
e4fc6f9081 | ||
|
|
cb751211f1 | ||
|
|
e5a3aa103d | ||
|
|
52957ec244 | ||
|
|
a49fa3648f | ||
|
|
cc698f561e | ||
|
|
f46c9c6548 | ||
|
|
154408fa8b | ||
|
|
20ee462cab | ||
|
|
293dab6a51 | ||
|
|
bb23e1b700 | ||
|
|
2b77f96fc5 | ||
|
|
e61d85a890 | ||
|
|
2c2cdd077f | ||
|
|
c83a57b2bd | ||
|
|
1d5cb1e051 | ||
|
|
6f94627bf4 | ||
|
|
7ca4db9c64 | ||
|
|
a1c79f42ff | ||
|
|
6225c8123c | ||
|
|
ffefe3002f | ||
|
|
df03886053 | ||
|
|
eae8d47cee | ||
|
|
c38fed70be | ||
|
|
8ee4080d69 | ||
|
|
5d81dcb549 | ||
|
|
88d44cf4ea | ||
|
|
a317984da1 | ||
|
|
4dab4e20c2 | ||
|
|
525653b68d | ||
|
|
bab0636014 | ||
|
|
2765ff5555 | ||
|
|
b6920a5691 | ||
|
|
586bc21dd3 | ||
|
|
4a602f7e46 | ||
|
|
0dc09cab8c | ||
|
|
63519433f1 | ||
|
|
1f19fb0d9f | ||
|
|
f13601cb9f | ||
|
|
1fa454f7ad | ||
|
|
85dd8f4176 | ||
|
|
850aab865e | ||
|
|
387c478b25 | ||
|
|
3606f48003 | ||
|
|
79dfc4b8cb | ||
|
|
0b6de0aa77 | ||
|
|
be22f4c1f8 | ||
|
|
e5cc7fadeb | ||
|
|
d5f8963d02 | ||
|
|
95bee73624 | ||
|
|
ffed2035c8 | ||
|
|
607e6e2be4 | ||
|
|
ba448b8617 | ||
|
|
a4472f8788 | ||
|
|
a2df2b1b3b | ||
|
|
3fe6a04e7c | ||
|
|
1f4155c464 | ||
|
|
d4e49b59ff | ||
|
|
1d0bbb39d1 | ||
|
|
dada6a42fc | ||
|
|
4bb4a6622f | ||
|
|
90deb2439f | ||
|
|
5cd731594f | ||
|
|
582582e480 | ||
|
|
173a364dae | ||
|
|
0c0191332a | ||
|
|
99d705e597 | ||
|
|
3829a1e745 | ||
|
|
df024f1c6e | ||
|
|
726f98027a | ||
|
|
0a114228a8 | ||
|
|
880ed2c78e | ||
|
|
9fbc1fa477 | ||
|
|
8b5c62e6fc | ||
|
|
040ffbb8ca | ||
|
|
3b0965520b | ||
|
|
68a7b17f36 | ||
|
|
b122e3638f | ||
|
|
08fd2a8184 | ||
|
|
fe2115ee5c | ||
|
|
bc60f5116b | ||
|
|
b65396ef06 | ||
|
|
851dab4daf | ||
|
|
9488631862 | ||
|
|
d4799dce54 | ||
|
|
00bda60102 | ||
|
|
794a0e3c1e | ||
|
|
a33d304d53 | ||
|
|
004f642622 | ||
|
|
33150f82ea | ||
|
|
6baf42fa4a | ||
|
|
523d9ef400 | ||
|
|
c378f4ead1 | ||
|
|
f927f6a751 | ||
|
|
7ae1028427 | ||
|
|
13fea24739 | ||
|
|
bc1228b312 | ||
|
|
932c57f9a9 | ||
|
|
87782448b6 | ||
|
|
912a5f17b1 | ||
|
|
ea57c9e9ff | ||
|
|
ac7d6dd542 | ||
|
|
666089edbb | ||
|
|
f525be1e0d | ||
|
|
990ca57fda | ||
|
|
b42c6107c9 | ||
|
|
c17281f9c2 | ||
|
|
1df47afc17 | ||
|
|
8a36e7ad7d | ||
|
|
c245e0a09d | ||
|
|
edd93851a4 | ||
|
|
7ce66c7939 | ||
|
|
d5a9202ddf | ||
|
|
d7cf73cc24 | ||
|
|
a0389defcc | ||
|
|
aded0e2d8b | ||
|
|
5fec4f41e4 | ||
|
|
e461abaafa | ||
|
|
f1d5a9415e | ||
|
|
9c9cce00ea | ||
|
|
800d9a6af9 | ||
|
|
c4535ef77c | ||
|
|
a1d7d3367a | ||
|
|
b2d7da04e5 | ||
|
|
995cad17fd | ||
|
|
d507e97996 | ||
|
|
a593f864ab | ||
|
|
d29d961c4f | ||
|
|
a1054c3a29 | ||
|
|
25be56aa3e | ||
|
|
99876cfb7c | ||
|
|
0483305edd | ||
|
|
26cbffe6c1 | ||
|
|
a541090f3a | ||
|
|
8dc8c54bca | ||
|
|
dbad7571ac | ||
|
|
c89d407a41 | ||
|
|
e08e9845a2 | ||
|
|
8e822a591d | ||
|
|
0eae222b88 | ||
|
|
66cb711066 | ||
|
|
9414c38154 | ||
|
|
d02b0b8eb6 | ||
|
|
c7904c4f63 | ||
|
|
aa304ad22f | ||
|
|
651305e8ce | ||
|
|
12a0f9a24c | ||
|
|
334699d264 | ||
|
|
8e78b6d8ad | ||
|
|
03c2f241b8 | ||
|
|
f2c12965f2 | ||
|
|
653a7a817f | ||
|
|
5bff9e8c5f | ||
|
|
475d108ccb | ||
|
|
527bad9cc2 | ||
|
|
47a5151a20 | ||
|
|
dd724fde4d | ||
|
|
a584cc217b | ||
|
|
5b72c4005b | ||
|
|
d2f6a3c96f | ||
|
|
61e2d5e0e1 | ||
|
|
029c93a466 | ||
|
|
12e1a601c8 | ||
|
|
7c00cea862 | ||
|
|
239be20cbf | ||
|
|
5f67b9ee42 | ||
|
|
6162b9f927 | ||
|
|
ad78376278 | ||
|
|
15b413c9c3 | ||
|
|
1868c7586d | ||
|
|
7f81066530 | ||
|
|
101dcc3ef2 | ||
|
|
0dc490c9bc | ||
|
|
1cfa46e921 | ||
|
|
fc89c7dd06 | ||
|
|
3bb729214e | ||
|
|
09694feaad | ||
|
|
3c953b47b0 | ||
|
|
8572393881 | ||
|
|
f95239006c | ||
|
|
1040afdda6 | ||
|
|
b0849c03e5 | ||
|
|
bc7afd7037 | ||
|
|
220efc05ca | ||
|
|
3d4247ab15 | ||
|
|
202efbbf85 | ||
|
|
bc4e1cd17e | ||
|
|
e9451af1be | ||
|
|
f1824469e4 | ||
|
|
0d79eb244b | ||
|
|
760f956f91 | ||
|
|
15a77eec13 | ||
|
|
641088c0fc | ||
|
|
096a6f65b3 | ||
|
|
2d67eb6650 | ||
|
|
db2e6ca12f | ||
|
|
992eea3eeb | ||
|
|
3a1e792e31 | ||
|
|
06199faf2c | ||
|
|
c206642d2d | ||
|
|
5bade79394 | ||
|
|
f2c4590902 | ||
|
|
2ceb68e691 | ||
|
|
9cfef027aa | ||
|
|
0b4b04eefb | ||
|
|
0a7b535533 | ||
|
|
17c2022a6f | ||
|
|
cce3ceb5b6 | ||
|
|
fcd91cb0b0 | ||
|
|
3692014070 | ||
|
|
85c5ad6718 | ||
|
|
bef919c7f0 | ||
|
|
d39f6a898a | ||
|
|
43ae30026a | ||
|
|
27c46b01ae | ||
|
|
cbe16a3724 | ||
|
|
54af29050f | ||
|
|
3979ddc40a | ||
|
|
967cb56c18 | ||
|
|
c65d4f9672 | ||
|
|
73788f9e88 | ||
|
|
2acd47b5ee | ||
|
|
b3cf1dfb54 | ||
|
|
35a50012c7 | ||
|
|
83295e655d | ||
|
|
e2790fe95d | ||
|
|
b608fb23f0 | ||
|
|
829db06d5b | ||
|
|
2e053ad76b | ||
|
|
c942efb76b | ||
|
|
fdcf9931be | ||
|
|
e61bd487fa | ||
|
|
7deba88b91 | ||
|
|
980f976011 | ||
|
|
c00fa4cd70 | ||
|
|
ef8e66a924 | ||
|
|
e8ffc80dc6 | ||
|
|
3920ebe25b | ||
|
|
0a50e721aa | ||
|
|
5b407566db | ||
|
|
f327d5bbc2 | ||
|
|
2a8bb86fbb | ||
|
|
7dae50b0c9 | ||
|
|
d68053ea7f | ||
|
|
8ca9741845 | ||
|
|
c9c312c4ba | ||
|
|
5dca6fe2e2 | ||
|
|
fdc5436249 | ||
|
|
7d22cc2155 | ||
|
|
42d1dd836c | ||
|
|
15e7461a93 | ||
|
|
0fdaf133bb | ||
|
|
d4584aafda | ||
|
|
5b3c4f1546 | ||
|
|
25302fb333 | ||
|
|
2f02f19cec | ||
|
|
82e0e454d0 | ||
|
|
650bdd2294 | ||
|
|
cb2d99c8cf | ||
|
|
42f03fe1a2 | ||
|
|
fc2847fdb4 | ||
|
|
d6e80e8954 | ||
|
|
39b51d5dae | ||
|
|
8e98e97449 | ||
|
|
f5c32c29f1 | ||
|
|
98b999d911 | ||
|
|
0e8e3200a2 | ||
|
|
73322fd310 | ||
|
|
97b074ad0c | ||
|
|
541458c41b | ||
|
|
df24a3b683 | ||
|
|
966af9dd68 | ||
|
|
b6fcd32dcf | ||
|
|
35a990ed65 | ||
|
|
f9573402a7 | ||
|
|
437dcc6c41 | ||
|
|
5a15660c77 | ||
|
|
0706d464b6 | ||
|
|
8d49b88748 | ||
|
|
5900affe37 | ||
|
|
bda3617d14 | ||
|
|
bd24288a12 | ||
|
|
3b10d66bb9 | ||
|
|
41b1cd7185 | ||
|
|
eeb233bf99 | ||
|
|
8b95db1574 | ||
|
|
37e7c618b8 | ||
|
|
84b90b1f4c | ||
|
|
4e89e88845 | ||
|
|
d867710cc9 | ||
|
|
526f54595d | ||
|
|
3c3f58a7be | ||
|
|
e4ab2156f1 | ||
|
|
6bba2906bc | ||
|
|
95cf27745b | ||
|
|
a9baa3b2d1 | ||
|
|
0186219586 | ||
|
|
cca428aac6 | ||
|
|
113e1b7a62 | ||
|
|
ff69fdacc7 | ||
|
|
6c64bc33c1 | ||
|
|
fda3f1be94 | ||
|
|
e93ae7b430 | ||
|
|
4ee1a3d766 | ||
|
|
cc10eb1f2a | ||
|
|
d16075f39e | ||
|
|
f436b5ae09 | ||
|
|
ceaab349f1 | ||
|
|
22654bf518 | ||
|
|
c061412138 | ||
|
|
89b029aa42 | ||
|
|
2c7bafe3c1 | ||
|
|
bcb7eabff3 | ||
|
|
e63f471c77 | ||
|
|
1fc72c68dd | ||
|
|
1bd2ab00ac | ||
|
|
e713e8eade | ||
|
|
26fa234026 | ||
|
|
6c24fa728e | ||
|
|
0fedd1dbea | ||
|
|
722f73dfbe | ||
|
|
7d6916b946 | ||
|
|
ada5db011c | ||
|
|
099141f6c5 | ||
|
|
6a4033b6bc |
@ -2,4 +2,4 @@
|
||||
|
||||
请移步 GitHub issues 进行反馈:
|
||||
|
||||
https://github.com/youzan/vant/issues
|
||||
https://github.com/vant-ui/vant/issues
|
||||
|
||||
2
.github/CONTRIBUTING.md
vendored
2
.github/CONTRIBUTING.md
vendored
@ -29,7 +29,7 @@ It's welcomed to pull request, And there are some tips about that:
|
||||
You will need [Node.js >= 14](https://nodejs.org) and [pnpm](https://pnpm.io).
|
||||
|
||||
```bash
|
||||
git clone git@github.com:youzan/vant.git
|
||||
git clone git@github.com:vant-ui/vant.git
|
||||
|
||||
# Install dependencies
|
||||
pnpm i
|
||||
|
||||
@ -9,14 +9,14 @@ body:
|
||||
在提交 Bug 报告前,请注意:
|
||||
|
||||
- 确认你的问题无法通过官方文档得到解决。
|
||||
- 确认你搜索过 [历史 issue](https://github.com/youzan/vant/issues),并且没有发现同样的问题。
|
||||
- 如果不是反馈 Bug,请到 [Discussions 讨论区](https://github.com/youzan/vant/discussions) 发帖。
|
||||
- 确认你搜索过 [历史 issue](https://github.com/vant-ui/vant/issues),并且没有发现同样的问题。
|
||||
- 如果不是反馈 Bug,请到 [Discussions 讨论区](https://github.com/vant-ui/vant/discussions) 发帖。
|
||||
|
||||
- type: input
|
||||
id: reproduce
|
||||
attributes:
|
||||
label: 重现链接
|
||||
description: 请提供一个尽可能简单的 [codesandbox](https://codesandbox.io/s/m5v3f) 或 GitHub 仓库链接。不要填写无效的链接,这会导致你的 issue 被直接关闭。
|
||||
description: 请提供一个尽可能简单的 [codesandbox](https://codesandbox.io/s/vant-3-issue-template-8fuq5o) 或 GitHub 仓库链接。不要填写无效的链接,这会导致你的 issue 被直接关闭。
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
@ -9,14 +9,14 @@ body:
|
||||
在提交 Bug 报告前,请注意:
|
||||
|
||||
- 确认你的问题无法通过官方文档得到解决。
|
||||
- 确认你搜索过 [历史 issue](https://github.com/youzan/vant/issues),并且没有发现同样的问题。
|
||||
- 如果不是反馈 Bug,请到 [Discussions 讨论区](https://github.com/youzan/vant/discussions) 发帖。
|
||||
- 确认你搜索过 [历史 issue](https://github.com/vant-ui/vant/issues),并且没有发现同样的问题。
|
||||
- 如果不是反馈 Bug,请到 [Discussions 讨论区](https://github.com/vant-ui/vant/discussions) 发帖。
|
||||
|
||||
- type: input
|
||||
id: reproduce
|
||||
attributes:
|
||||
label: 重现链接
|
||||
description: 请提供一个尽可能简单的 [codesandbox](https://codesandbox.io/s/m5v3f) 或 GitHub 仓库链接。不要填写无效的链接,这会导致你的 issue 被直接关闭。
|
||||
description: 请提供一个尽可能简单的 [codesandbox](https://codesandbox.io/s/vant-3-issue-template-8fuq5o) 或 GitHub 仓库链接。不要填写无效的链接,这会导致你的 issue 被直接关闭。
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
@ -9,8 +9,8 @@ body:
|
||||
在提交功能需求前,请注意:
|
||||
|
||||
- 确认这是一个通用功能,并且无法通过现有的 API 或 Slot 实现。
|
||||
- 确认你搜索过 [历史 issue](https://github.com/youzan/vant/issues),并且没有发现同样的需求。
|
||||
- 可以先到 [Discussions 讨论区](https://github.com/youzan/vant/discussions) 发帖,讨论一下需求是否合理。
|
||||
- 确认你搜索过 [历史 issue](https://github.com/vant-ui/vant/issues),并且没有发现同样的需求。
|
||||
- 可以先到 [Discussions 讨论区](https://github.com/vant-ui/vant/discussions) 发帖,讨论一下需求是否合理。
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
|
||||
@ -9,8 +9,8 @@ body:
|
||||
在提交功能需求前,请注意:
|
||||
|
||||
- 确认这是一个通用功能,并且无法通过现有的 API 实现。
|
||||
- 确认你搜索过 [历史 issue](https://github.com/youzan/vant/issues),并且没有发现同样的需求。
|
||||
- 可以先到 [Discussions 讨论区](https://github.com/youzan/vant/discussions) 发帖,讨论一下需求是否合理。
|
||||
- 确认你搜索过 [历史 issue](https://github.com/vant-ui/vant/issues),并且没有发现同样的需求。
|
||||
- 可以先到 [Discussions 讨论区](https://github.com/vant-ui/vant/discussions) 发帖,讨论一下需求是否合理。
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
|
||||
@ -7,7 +7,7 @@ body:
|
||||
id: reproduce
|
||||
attributes:
|
||||
label: Reproduction Link
|
||||
description: Please provide a simple [codesandbox](https://codesandbox.io/s/m5v3f) or GitHub repository link. Do not fill in invalid links, this will cause your issue to be closed directly.
|
||||
description: Please provide a simple [codesandbox](https://codesandbox.io/s/vant-3-issue-template-8fuq5o) or GitHub repository link. Do not fill in invalid links, this will cause your issue to be closed directly.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,6 +1,6 @@
|
||||
### Before submitting a pull request, please make sure the following is done:
|
||||
|
||||
1. Read the [contributing guide](https://github.com/youzan/vant/blob/dev/.github/CONTRIBUTING.md).
|
||||
1. Read the [contributing guide](https://github.com/vant-ui/vant/blob/dev/.github/CONTRIBUTING.md).
|
||||
2. If you've added code that should be tested, add tests.
|
||||
3. If you've changed APIs, update the documentation.
|
||||
4. Ensure the test suite passes (`npm test`).
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
name: Deploy V3 Site
|
||||
name: Deploy V4 Site
|
||||
|
||||
on:
|
||||
push:
|
||||
@ -6,6 +6,8 @@ on:
|
||||
paths:
|
||||
- 'packages/vant/docs/**'
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
@ -13,12 +15,10 @@ jobs:
|
||||
- name: Checkout 🛎️
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: 'dev'
|
||||
ref: 'next'
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.0.1
|
||||
with:
|
||||
version: 6.20.3
|
||||
run: npm i pnpm@7 -g
|
||||
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
@ -36,4 +36,5 @@ jobs:
|
||||
with:
|
||||
branch: gh-pages
|
||||
folder: packages/vant/site-dist
|
||||
target-folder: v4
|
||||
clean: false
|
||||
4
.github/workflows/release-tag.yml
vendored
4
.github/workflows/release-tag.yml
vendored
@ -20,6 +20,6 @@ jobs:
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
body: |
|
||||
更新内容参见 [CHANGELOG](https://youzan.github.io/vant/#/zh-CN/changelog)。
|
||||
更新内容参见 [CHANGELOG](https://vant-ui.github.io/vant/#/zh-CN/changelog)。
|
||||
|
||||
Please refer to [CHANGELOG](https://youzan.github.io/vant/#/en-US/changelog) for details.
|
||||
Please refer to [CHANGELOG](https://vant-ui.github.io/vant/#/en-US/changelog) for details.
|
||||
|
||||
6
.github/workflows/sync-gitee.yml
vendored
6
.github/workflows/sync-gitee.yml
vendored
@ -2,7 +2,9 @@ name: Sync to Gitee
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [dev, 2.x, gh-pages]
|
||||
branches: [dev, 2.x, 3.x, gh-pages]
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -15,6 +17,6 @@ jobs:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }}
|
||||
with:
|
||||
# GitHub 源仓库地址
|
||||
source-repo: git@github.com:youzan/vant.git
|
||||
source-repo: git@github.com:vant-ui/vant.git
|
||||
# Gitee 目标仓库地址
|
||||
destination-repo: git@gitee.com:vant-contrib/vant.git
|
||||
|
||||
23
.github/workflows/test.yml
vendored
23
.github/workflows/test.yml
vendored
@ -1,6 +1,15 @@
|
||||
name: CI
|
||||
|
||||
on: [push, pull_request]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- dev
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
@ -9,9 +18,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.0.1
|
||||
with:
|
||||
version: 6.20.3
|
||||
run: npm i pnpm@7 -g
|
||||
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
@ -30,9 +37,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.0.1
|
||||
with:
|
||||
version: 6.20.3
|
||||
run: npm i pnpm@7 -g
|
||||
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
@ -56,9 +61,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.0.1
|
||||
with:
|
||||
version: 6.20.3
|
||||
run: npm i pnpm@7 -g
|
||||
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,6 +15,5 @@ package-lock.json
|
||||
es
|
||||
lib
|
||||
dist
|
||||
vetur
|
||||
**/site-dist
|
||||
changelog.generated.md
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
npx --no-install lint-staged
|
||||
npx --no-install nano-staged
|
||||
|
||||
2
.npmrc
2
.npmrc
@ -1 +1,3 @@
|
||||
registry=https://registry.npmmirror.com/
|
||||
|
||||
strict-peer-dependencies=false
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": ["@vant/stylelint-config"]
|
||||
}
|
||||
5
LICENSE
5
LICENSE
@ -1,4 +1,7 @@
|
||||
Copyright 2016-present Youzan
|
||||
MIT License
|
||||
|
||||
Copyright (c) Youzan
|
||||
Copyright (c) Chen Jiahan and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
46
README.md
46
README.md
@ -1,24 +1,23 @@
|
||||
<p align="center">
|
||||
<img alt="logo" src="https://img.yzcdn.cn/vant/logo.png" width="120" height="120" style="margin-bottom: 10px;">
|
||||
<img alt="logo" src="https://fastly.jsdelivr.net/npm/@vant/assets/logo.png" width="120" height="120" style="margin-bottom: 10px;">
|
||||
</p>
|
||||
|
||||
<h1 align="center">Vant</h1>
|
||||
|
||||
<p align="center">Mobile UI Components built on Vue</p>
|
||||
<p align="center">Lightweight Mobile UI Components built on Vue</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/npm/v/vant?style=flat-square" alt="npm version" />
|
||||
<img src="https://img.shields.io/github/workflow/status/youzan/vant/CI/dev?style=flat-square" alt="CI Status" />
|
||||
<img src="https://img.shields.io/codecov/c/github/youzan/vant/dev.svg?style=flat-square&color=#4fc08d" alt="Coverage Status" />
|
||||
<img src="https://img.shields.io/github/workflow/status/vant-ui/vant/CI/dev?style=flat-square" alt="CI Status" />
|
||||
<img src="https://img.shields.io/codecov/c/github/vant-ui/vant/dev.svg?style=flat-square&color=#4fc08d" alt="Coverage Status" />
|
||||
<img src="https://img.shields.io/npm/dm/vant.svg?style=flat-square&color=#4fc08d" alt="downloads" />
|
||||
<img src="https://img.shields.io/jsdelivr/npm/hm/vant?style=flat-square" alt="Jsdelivr Hits">
|
||||
<img src="https://img.badgesize.io/https://unpkg.com/vant@3/lib/vant.min.js?compression=gzip&style=flat-square&label=gzip%20size&color=#4fc08d" alt="Gzip Size" />
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
🔥 <a href="https://vant-contrib.gitee.io/vant">文档网站(国内)</a>
|
||||
|
||||
🌈 <a href="https://youzan.github.io/vant">文档网站(GitHub)</a>
|
||||
🌈 <a href="https://vant-ui.github.io/vant">文档网站(GitHub)</a>
|
||||
|
||||
🇨🇳 <a href="./README.zh-CN.md">中文版介绍</a>
|
||||
</p>
|
||||
@ -28,7 +27,8 @@
|
||||
## Features
|
||||
|
||||
- 🚀 1KB Component average size (min+gzip)
|
||||
- 🚀 65+ High quality components
|
||||
- 🚀 70+ High quality components
|
||||
- 🚀 Zero third-party dependencies
|
||||
- 💪 90%+ Unit test coverage
|
||||
- 💪 Written in TypeScript
|
||||
- 📖 Extensive documentation and demos
|
||||
@ -37,8 +37,9 @@
|
||||
- 🍭 Support Tree Shaking
|
||||
- 🍭 Support Custom Theme
|
||||
- 🍭 Support Accessibility (still improving)
|
||||
- 🍭 Support i18n
|
||||
- 🌍 Support SSR
|
||||
- 🍭 Support Dark Mode (Requires upgrade to [Vant 4](https://vant-contrib.gitee.io/vant/v4/#/en-US/config-provider))
|
||||
- 🍭 Support SSR
|
||||
- 🌍 Support i18n, built-in 20+ languages
|
||||
|
||||
## Install
|
||||
|
||||
@ -66,30 +67,34 @@ pnpm add vant
|
||||
|
||||
```js
|
||||
import { createApp } from 'vue';
|
||||
// 1. Import the components you need
|
||||
import { Button } from 'vant';
|
||||
// 2. Import the components style
|
||||
import 'vant/lib/index.css';
|
||||
|
||||
const app = createApp();
|
||||
|
||||
// 3. Register the components you need
|
||||
app.use(Button);
|
||||
```
|
||||
|
||||
See more in [Quickstart](https://youzan.github.io/vant#/en-US/quickstart).
|
||||
See more in [Quickstart](https://vant-ui.github.io/vant#/en-US/quickstart).
|
||||
|
||||
## Browser Support
|
||||
|
||||
Vant 2 supports modern browsers and Android >= 4.0、iOS >= 8.0.
|
||||
|
||||
Vant 3 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3).
|
||||
Vant 3/4 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3).
|
||||
|
||||
## Official Ecosystem
|
||||
|
||||
| Project | Description |
|
||||
| --- | --- |
|
||||
| [vant-weapp](https://github.com/youzan/vant-weapp) | WeChat MiniProgram UI |
|
||||
| [vant-demo](https://github.com/youzan/vant-demo) | Collection of Vant demos |
|
||||
| [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | Scaffold for UI library |
|
||||
| [vant-icons](https://github.com/youzan/vant/tree/dev/packages/vant-icons) | Vant icons |
|
||||
| [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | Using vant in desktop browsers |
|
||||
| [vant-weapp](https://github.com/vant-ui/vant-weapp) | WeChat MiniProgram UI |
|
||||
| [vant-demo](https://github.com/vant-ui/vant-demo) | Collection of Vant demos |
|
||||
| [vant-cli](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli) | Scaffold for UI library |
|
||||
| [vant-icons](https://github.com/vant-ui/vant/tree/dev/packages/vant-icons) | Vant icons |
|
||||
| [vant-touch-emulator](https://github.com/vant-ui/vant/tree/dev/packages/vant-touch-emulator) | Using vant in desktop browsers |
|
||||
|
||||
## Community Ecosystem
|
||||
|
||||
@ -101,18 +106,19 @@ Vant 3 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3).
|
||||
| [taroify](https://gitee.com/mallfoundry/taroify) | Vant Taro |
|
||||
| [vant-theme](https://github.com/Aisen60/vant-theme) | Online theme preview built on Vant UI |
|
||||
| [@antmjs/vantui](https://github.com/antmjs/vantui) | Mobile UI Components based on Vant, supporting Taro and React |
|
||||
| [sfc-playground-vant](https://github.com/zhixiaoqiang/sfc-playground-vant) | Try Vant in the Playground. Currently only Vant 3+ is supported |
|
||||
|
||||
## Links
|
||||
|
||||
- [Documentation](https://youzan.github.io/vant)
|
||||
- [Changelog](https://youzan.github.io/vant#/en-US/changelog)
|
||||
- [Documentation](https://vant-ui.github.io/vant)
|
||||
- [Changelog](https://vant-ui.github.io/vant#/en-US/changelog)
|
||||
- [Gitter](https://gitter.im/vant-contrib/discuss?utm_source=share-link&utm_medium=link&utm_campaign=share-link)
|
||||
|
||||
## Preview
|
||||
|
||||
You can scan the following QR code to access the demo:
|
||||
|
||||
<img src="https://img.yzcdn.cn/vant/preview_qrcode_20180528.png" width="220" height="220" >
|
||||
<img src="https://fastly.jsdelivr.net/npm/@vant/assets/preview-qrcode.png" width="220" height="220" >
|
||||
|
||||
## Core Team
|
||||
|
||||
@ -126,7 +132,7 @@ Core contributors of Vant and Vant Weapp:
|
||||
|
||||
Thanks to the following friends for their contributions to Vant:
|
||||
|
||||
<a href="https://github.com/youzan/vant/graphs/contributors">
|
||||
<a href="https://github.com/vant-ui/vant/graphs/contributors">
|
||||
<img src="https://opencollective.com/vant/contributors.svg?width=890&button=false" alt="contributors">
|
||||
</a>
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<p align="center">
|
||||
<img alt="logo" src="https://img.yzcdn.cn/vant/logo.png" width="120" style="margin-bottom: 10px;">
|
||||
<img alt="logo" src="https://fastly.jsdelivr.net/npm/@vant/assets/logo.png" width="120" style="margin-bottom: 10px;">
|
||||
</p>
|
||||
|
||||
<h1 align="center">Vant</h1>
|
||||
@ -8,41 +8,42 @@
|
||||
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/npm/v/vant?style=flat-square" alt="npm version" />
|
||||
<img src="https://img.shields.io/github/workflow/status/youzan/vant/CI/dev?style=flat-square" alt="CI Status" />
|
||||
<img src="https://img.shields.io/codecov/c/github/youzan/vant/dev.svg?style=flat-square&color=#4fc08d" alt="Coverage Status" />
|
||||
<img src="https://img.shields.io/github/workflow/status/vant-ui/vant/CI/dev?style=flat-square" alt="CI Status" />
|
||||
<img src="https://img.shields.io/codecov/c/github/vant-ui/vant/dev.svg?style=flat-square&color=#4fc08d" alt="Coverage Status" />
|
||||
<img src="https://img.shields.io/npm/dm/vant.svg?style=flat-square&color=#4fc08d" alt="downloads" />
|
||||
<img src="https://img.shields.io/jsdelivr/npm/hm/vant?style=flat-square" alt="Jsdelivr Hits">
|
||||
<img src="https://img.badgesize.io/https://unpkg.com/vant@3/lib/vant.min.js?compression=gzip&style=flat-square&label=gzip%20size&color=#4fc08d" alt="Gzip Size" />
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
🔥 <a href="https://vant-contrib.gitee.io/vant">文档网站(国内)</a>
|
||||
|
||||
🌈 <a href="https://youzan.github.io/vant">文档网站(GitHub)</a>
|
||||
🌈 <a href="https://vant-ui.github.io/vant">文档网站(GitHub)</a>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
### 介绍
|
||||
|
||||
Vant 是**有赞前端团队**开源的移动端组件库,于 2017 年开源。Vant 对内承载了有赞所有核心业务,对外服务十多万开发者,是业界主流的移动端组件库之一。
|
||||
Vant 是一个**轻量、可靠的移动端组件库**,于 2017 年开源。
|
||||
|
||||
目前 Vant 官方提供了 [Vue 2 版本](https://vant-contrib.gitee.io/vant/v2)、[Vue 3 版本](https://vant-contrib.gitee.io/vant)和[微信小程序版本](http://vant-contrib.gitee.io/vant-weapp),并由社区团队维护 [React 版本](https://github.com/mxdi9i7/vant-react)和[支付宝小程序版本](https://github.com/ant-move/Vant-Aliapp)。
|
||||
目前 Vant 官方提供了 [Vue 2 版本](https://vant-contrib.gitee.io/vant/v2)、[Vue 3 版本](https://vant-contrib.gitee.io/vant)和[微信小程序版本](http://vant-contrib.gitee.io/vant-weapp),并由社区团队维护 [React 版本](https://github.com/3lang3/react-vant)和[支付宝小程序版本](https://github.com/ant-move/Vant-Aliapp)。
|
||||
|
||||
## 特性
|
||||
|
||||
- 🚀 性能极佳,组件平均体积小于 1KB(min+gzip)
|
||||
- 🚀 65+ 个高质量组件,覆盖移动端主流场景
|
||||
- 🚀 70+ 个高质量组件,覆盖移动端主流场景
|
||||
- 🚀 零外部依赖,不依赖三方 npm 包
|
||||
- 💪 使用 TypeScript 编写,提供完整的类型定义
|
||||
- 💪 单元测试覆盖率超过 90%,提供稳定性保障
|
||||
- 📖 提供完善的中英文文档和组件示例
|
||||
- 📖 提供丰富的中英文文档和组件示例
|
||||
- 📖 提供 Sketch 和 Axure 设计资源
|
||||
- 🍭 支持 Vue 2、Vue 3 和微信小程序
|
||||
- 🍭 支持主题定制,内置 700+ 个主题变量
|
||||
- 🍭 支持按需引入和 Tree Shaking
|
||||
- 🍭 支持无障碍访问(持续改进中)
|
||||
- 🍭 支持深色模式(从 [Vant 4](https://vant-contrib.gitee.io/vant/v4/#/zh-CN/config-provider) 开始支持)
|
||||
- 🍭 支持服务器端渲染
|
||||
- 🌍 支持国际化和语言包定制
|
||||
- 🌍 支持国际化,内置 20+ 种语言包
|
||||
|
||||
## 安装
|
||||
|
||||
@ -70,10 +71,14 @@ pnpm add vant
|
||||
|
||||
```js
|
||||
import { createApp } from 'vue';
|
||||
// 1. 引入你需要的组件
|
||||
import { Button } from 'vant';
|
||||
// 2. 引入组件样式
|
||||
import 'vant/lib/index.css';
|
||||
|
||||
const app = createApp();
|
||||
|
||||
// 3. 注册你需要的组件
|
||||
app.use(Button);
|
||||
```
|
||||
|
||||
@ -83,7 +88,7 @@ vant 也支持按需引入、CDN 引入等方式,详细说明见 [快速上手
|
||||
|
||||
Vant 2 支持现代浏览器以及 Android >= 4.0、iOS >= 8.0。
|
||||
|
||||
Vant 3 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一致)。
|
||||
Vant 3/4 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一致)。
|
||||
|
||||
## 官方生态
|
||||
|
||||
@ -91,11 +96,11 @@ Vant 3 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一致
|
||||
|
||||
| 项目 | 描述 |
|
||||
| --- | --- |
|
||||
| [vant-weapp](https://github.com/youzan/vant-weapp) | Vant 微信小程序版 |
|
||||
| [vant-demo](https://github.com/youzan/vant-demo) | Vant 官方示例合集 |
|
||||
| [vant-cli](https://github.com/youzan/vant/tree/dev/packages/vant-cli) | 开箱即用的组件库搭建工具 |
|
||||
| [vant-icons](https://github.com/youzan/vant/tree/dev/packages/vant-icons) | Vant 图标库 |
|
||||
| [vant-touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) | 在桌面端使用 Vant 的辅助库 |
|
||||
| [vant-weapp](https://github.com/vant-ui/vant-weapp) | Vant 微信小程序版 |
|
||||
| [vant-demo](https://github.com/vant-ui/vant-demo) | Vant 官方示例合集 |
|
||||
| [vant-cli](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli) | 开箱即用的组件库搭建工具 |
|
||||
| [vant-icons](https://github.com/vant-ui/vant/tree/dev/packages/vant-icons) | Vant 图标库 |
|
||||
| [vant-touch-emulator](https://github.com/vant-ui/vant/tree/dev/packages/vant-touch-emulator) | 在桌面端使用 Vant 的辅助库 |
|
||||
|
||||
## 社区生态
|
||||
|
||||
@ -109,6 +114,7 @@ Vant 3 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一致
|
||||
| [taroify](https://gitee.com/mallfoundry/taroify) | Vant Taro 版 |
|
||||
| [vant-theme](https://github.com/Aisen60/vant-theme) | Vant 在线主题预览工具 |
|
||||
| [@antmjs/vantui](https://github.com/antmjs/vantui) | 基于 Vant Weapp 开发的多端组件库,同时支持 Taro 和 React |
|
||||
| [sfc-playground-vant](https://github.com/zhixiaoqiang/sfc-playground-vant) | Vant Playground. 当前仅支持 Vant 3.0 以上 |
|
||||
|
||||
## 链接
|
||||
|
||||
@ -120,7 +126,7 @@ Vant 3 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一致
|
||||
|
||||
可以手机扫码以下二维码访问手机端 demo:
|
||||
|
||||
<img src="https://img.yzcdn.cn/vant/preview_qrcode_20180528.png" width="220" height="220" >
|
||||
<img src="https://fastly.jsdelivr.net/npm/@vant/assets/preview-qrcode.png" width="220" height="220" >
|
||||
|
||||
## 核心团队
|
||||
|
||||
@ -134,7 +140,7 @@ Vant 3 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一致
|
||||
|
||||
感谢以下小伙伴们为 Vant 发展做出的贡献:
|
||||
|
||||
<a href="https://github.com/youzan/vant/graphs/contributors">
|
||||
<a href="https://github.com/vant-ui/vant/graphs/contributors">
|
||||
<img src="https://opencollective.com/vant/contributors.svg?width=890&button=false" alt="contributors">
|
||||
</a>
|
||||
|
||||
@ -142,7 +148,7 @@ Vant 3 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一致
|
||||
|
||||
修改代码请阅读我们的 [贡献指南](https://vant-contrib.gitee.io/vant/#/zh-CN/contribution)。
|
||||
|
||||
使用过程中发现任何问题都可以提 [Issue](https://github.com/youzan/vant/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://github.com/youzan/vant/pulls)。
|
||||
使用过程中发现任何问题都可以提 [Issue](https://github.com/vant-ui/vant/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://github.com/vant-ui/vant/pulls)。
|
||||
|
||||
## 开源协议
|
||||
|
||||
|
||||
41
package.json
41
package.json
@ -2,29 +2,36 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"prepare": "husky install",
|
||||
"dev": "pnpm dev --dir ./packages/vant",
|
||||
"lint": "pnpm lint --dir ./packages/vant",
|
||||
"test": "pnpm test --dir ./packages/vant",
|
||||
"test:watch": "pnpm test:watch --dir ./packages/vant",
|
||||
"build": "pnpm build --dir ./packages/vant",
|
||||
"build:site": "pnpm build:site --dir ./packages/vant"
|
||||
"dev": "pnpm --dir ./packages/vant dev",
|
||||
"lint": "pnpm --dir ./packages/vant lint",
|
||||
"test": "pnpm --dir ./packages/vant test",
|
||||
"test:watch": "pnpm --dir ./packages/vant test:watch",
|
||||
"build": "pnpm --dir ./packages/vant build",
|
||||
"build:site": "pnpm --dir ./packages/vant build:site"
|
||||
},
|
||||
"lint-staged": {
|
||||
"nano-staged": {
|
||||
"*.md": "prettier --write",
|
||||
"*.{ts,tsx,js,vue,less}": "prettier --write",
|
||||
"*.{ts,tsx,js,vue}": "eslint --fix",
|
||||
"*.{vue,css,less}": "stylelint --fix"
|
||||
"*.{ts,tsx,js,vue}": "eslint --fix"
|
||||
},
|
||||
"packageManager": "pnpm",
|
||||
"packageManager": "pnpm@7.11.0",
|
||||
"devDependencies": {
|
||||
"@vant/cli": "workspace:*",
|
||||
"@vant/eslint-config": "workspace:*",
|
||||
"@vant/stylelint-config": "workspace:*",
|
||||
"eslint": "^8.2.0",
|
||||
"husky": "^7.0.4",
|
||||
"lint-staged": "^12.1.2",
|
||||
"prettier": "^2.5.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"stylelint": "^13.13.1"
|
||||
"eslint": "^8.23.0",
|
||||
"husky": "^8.0.1",
|
||||
"nano-staged": "^0.8.0",
|
||||
"prettier": "^2.7.1",
|
||||
"rimraf": "^3.0.2"
|
||||
},
|
||||
"pnpm": {
|
||||
"peerDependencyRules": {
|
||||
"ignoreMissing": [
|
||||
"@algolia/client-search",
|
||||
"@types/react",
|
||||
"react",
|
||||
"react-dom"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
packages/create-vant-cli-app/LICENSE
Normal file
10
packages/create-vant-cli-app/LICENSE
Normal file
@ -0,0 +1,10 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Youzan
|
||||
Copyright (c) Chen Jiahan and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@ -15,19 +15,17 @@
|
||||
"build": "vant-cli build",
|
||||
"release": "vant-cli release",
|
||||
"test:coverage": "open test/coverage/index.html",
|
||||
"build-site": "vant-cli build-site && gh-pages -d site-dist"
|
||||
"build-site": "vant-cli build-site && npx gh-pages -d site-dist"
|
||||
},
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged",
|
||||
"pre-commit": "nano-staged",
|
||||
"commit-msg": "vant-cli commit-lint"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{ts,tsx,js,jsx,vue}": "eslint --fix",
|
||||
"*.{vue,css,less,scss}": "stylelint --fix"
|
||||
"nano-staged": {
|
||||
"*.{ts,tsx,js,jsx,vue}": "eslint --fix"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": "^2.6.11",
|
||||
@ -35,7 +33,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vant/cli": "^2.0.0",
|
||||
"babel-plugin-import": "^1.13.0",
|
||||
"vue": "^2.6.11",
|
||||
"vue-template-compiler": "^2.6.11"
|
||||
},
|
||||
@ -45,11 +42,6 @@
|
||||
"@vant"
|
||||
]
|
||||
},
|
||||
"stylelint": {
|
||||
"extends": [
|
||||
"@vant/stylelint-config"
|
||||
]
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true
|
||||
},
|
||||
|
||||
@ -10,7 +10,7 @@ module.exports = {
|
||||
},
|
||||
site: {
|
||||
title: '<%= name %>',
|
||||
logo: 'https://img.yzcdn.cn/vant/logo.png',
|
||||
logo: 'https://fastly.jsdelivr.net/npm/@vant/assets/logo.png',
|
||||
nav: [
|
||||
{
|
||||
title: '开发指南',
|
||||
|
||||
@ -15,6 +15,5 @@ test/coverage
|
||||
es
|
||||
lib
|
||||
dist
|
||||
vetur
|
||||
site
|
||||
changelog.generated.md
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
npx --no-install lint-staged
|
||||
npx --no-install nano-staged
|
||||
|
||||
@ -17,17 +17,15 @@
|
||||
"build": "vant-cli build",
|
||||
"build:site": "vant-cli build-site",
|
||||
"release": "vant-cli release --tag next",
|
||||
"release:site": "pnpm build:site && gh-pages -d site-dist",
|
||||
"release:site": "pnpm build:site && npx gh-pages -d site-dist",
|
||||
"test:watch": "vant-cli test --watch",
|
||||
"test:coverage": "open test/coverage/index.html"
|
||||
},
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"lint-staged": {
|
||||
"nano-staged": {
|
||||
"*.md": "prettier --write",
|
||||
"*.{ts,tsx,js,vue,less,scss}": "prettier --write",
|
||||
"*.{ts,tsx,js,vue}": "eslint --fix",
|
||||
"*.{vue,css,less,scss}": "stylelint --fix"
|
||||
"*.{ts,tsx,js,vue}": "eslint --fix"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": "^3.0.0"
|
||||
@ -43,11 +41,6 @@
|
||||
"@vant"
|
||||
]
|
||||
},
|
||||
"stylelint": {
|
||||
"extends": [
|
||||
"@vant/stylelint-config"
|
||||
]
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true
|
||||
},
|
||||
|
||||
@ -7,3 +7,7 @@
|
||||
<demo-button color="#03a9f4" style="margin-left: 15px">按钮</demo-button>
|
||||
</demo-block>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import DemoButton from '../index.vue';
|
||||
</script>
|
||||
|
||||
@ -10,7 +10,7 @@ export default {
|
||||
},
|
||||
site: {
|
||||
title: '<%= name %>',
|
||||
logo: 'https://img.yzcdn.cn/vant/logo.png',
|
||||
logo: 'https://fastly.jsdelivr.net/npm/@vant/assets/logo.png',
|
||||
nav: [
|
||||
{
|
||||
title: '开发指南',
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "create-vant-cli-app",
|
||||
"version": "2.0.0",
|
||||
"description": "Create Vant Cli App",
|
||||
"version": "2.0.1",
|
||||
"description": "Create Vant CLI App",
|
||||
"main": "lib/index.js",
|
||||
"bin": {
|
||||
"create-vant-cli-app": "./lib/index.js"
|
||||
@ -24,24 +24,24 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/youzan/vant.git",
|
||||
"url": "https://github.com/vant-ui/vant.git",
|
||||
"directory": "packages/create-vant-cli-app"
|
||||
},
|
||||
"bugs": "https://github.com/youzan/vant/issues",
|
||||
"bugs": "https://github.com/vant-ui/vant/issues",
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/inquirer": "^8.1.3",
|
||||
"release-it": "^14.11.6",
|
||||
"typescript": "~4.5.2"
|
||||
"@types/inquirer": "^8.2.3",
|
||||
"release-it": "^15.4.1",
|
||||
"typescript": "^4.8.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^4.1.2",
|
||||
"consola": "^2.11.3",
|
||||
"fast-glob": "^3.2.4",
|
||||
"fs-extra": "^10.0.0",
|
||||
"inquirer": "^8.0.0"
|
||||
"fast-glob": "^3.2.11",
|
||||
"fs-extra": "^10.1.0",
|
||||
"inquirer": "^8.2.4",
|
||||
"picocolors": "^1.0.0"
|
||||
},
|
||||
"release-it": {
|
||||
"git": {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import fs from 'fs-extra';
|
||||
import glob from 'fast-glob';
|
||||
import chalk from 'chalk';
|
||||
import color from 'picocolors';
|
||||
import consola from 'consola';
|
||||
import { prompt } from 'inquirer';
|
||||
import { sep, join } from 'path';
|
||||
@ -64,7 +64,7 @@ export class VanGenerator {
|
||||
|
||||
writing() {
|
||||
console.log();
|
||||
consola.info(`Creating project in ${chalk.green(this.outputDir)}\n`);
|
||||
consola.info(`Creating project in ${color.green(this.outputDir)}\n`);
|
||||
|
||||
// see https://github.com/mrmlnc/fast-glob#how-to-write-patterns-on-windows
|
||||
const templatePath = join(GENERATOR_DIR, this.inputs.vueVersion).replace(
|
||||
@ -99,16 +99,16 @@ export class VanGenerator {
|
||||
fs.writeFileSync(to, content);
|
||||
|
||||
const name = to.replace(this.outputDir + sep, '');
|
||||
consola.success(`${chalk.green('create')} ${name}`);
|
||||
consola.success(`${color.green('create')} ${name}`);
|
||||
}
|
||||
|
||||
end() {
|
||||
const { name } = this.inputs;
|
||||
|
||||
console.log();
|
||||
consola.success(`Successfully created ${chalk.yellow(name)}.`);
|
||||
consola.success(`Successfully created ${color.yellow(name)}.`);
|
||||
consola.success(
|
||||
`Run ${chalk.yellow(
|
||||
`Run ${color.yellow(
|
||||
`cd ${name} && git init && yarn && yarn dev`
|
||||
)} to start development!`
|
||||
);
|
||||
|
||||
10
packages/vant-area-data/LICENSE
Normal file
10
packages/vant-area-data/LICENSE
Normal file
@ -0,0 +1,10 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Youzan
|
||||
Copyright (c) Chen Jiahan and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@ -1,6 +1,6 @@
|
||||
# Vant Area Data
|
||||
|
||||
省市区数据,适用于 Vant Area 组件。
|
||||
中国省市区数据,适用于 Vant Area 组件。
|
||||
|
||||
## 安装
|
||||
|
||||
@ -20,3 +20,7 @@ pnpm add @vant/area-data
|
||||
```ts
|
||||
import { areaList } from '@vant/area-data';
|
||||
```
|
||||
|
||||
## 数据更新
|
||||
|
||||
中国的行政区划每年都会有变动,如果发现省市区数据未及时更新,欢迎提 Pull Request 帮助我们更新。
|
||||
|
||||
@ -1,10 +1,19 @@
|
||||
{
|
||||
"name": "@vant/area-data",
|
||||
"version": "1.2.2",
|
||||
"version": "1.3.2",
|
||||
"description": "Vant 省市区数据",
|
||||
"main": "dist/index.cjs.js",
|
||||
"module": "dist/index.esm.js",
|
||||
"module": "dist/index.esm.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.esm.mjs",
|
||||
"require": "./dist/index.cjs.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"clean": "rimraf ./dist",
|
||||
"dev": "node ./build.js -w",
|
||||
@ -20,16 +29,16 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/youzan/vant.git",
|
||||
"url": "https://github.com/vant-ui/vant.git",
|
||||
"directory": "packages/vant-area-data"
|
||||
},
|
||||
"bugs": "https://github.com/youzan/vant/issues",
|
||||
"bugs": "https://github.com/vant-ui/vant/issues",
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.14.21",
|
||||
"release-it": "^14.2.2",
|
||||
"typescript": "~4.5.2"
|
||||
"esbuild": "^0.14.54",
|
||||
"release-it": "^15.4.1",
|
||||
"typescript": "^4.8.2"
|
||||
},
|
||||
"release-it": {
|
||||
"git": {
|
||||
|
||||
@ -1150,10 +1150,10 @@ export const areaList = {
|
||||
232701: '漠河市',
|
||||
232721: '呼玛县',
|
||||
232722: '塔河县',
|
||||
232790: '松岭区',
|
||||
232791: '呼中区',
|
||||
232792: '加格达奇区',
|
||||
232793: '新林区',
|
||||
232761: '加格达奇区',
|
||||
232762: '松岭区',
|
||||
232763: '新林区',
|
||||
232764: '呼中区',
|
||||
310101: '黄浦区',
|
||||
310104: '徐汇区',
|
||||
310105: '长宁区',
|
||||
@ -1175,6 +1175,7 @@ export const areaList = {
|
||||
320105: '建邺区',
|
||||
320106: '鼓楼区',
|
||||
320111: '浦口区',
|
||||
320112: '江北新区',
|
||||
320113: '栖霞区',
|
||||
320114: '雨花台区',
|
||||
320115: '江宁区',
|
||||
|
||||
10
packages/vant-cli/LICENSE
Normal file
10
packages/vant-cli/LICENSE
Normal file
@ -0,0 +1,10 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Youzan
|
||||
Copyright (c) Chen Jiahan and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@ -1,36 +1,40 @@
|
||||
# Vant Cli
|
||||
# Vant CLI
|
||||
|
||||
Vant Cli 是一个 Vue 组件库构建工具,通过 Vant Cli 可以快速搭建一套功能完备的 Vue 组件库。
|
||||
Vant CLI is a tool for building vue component library. You can quickly build a full-featured Vue component library with vant-cli.
|
||||
|
||||
### 特性
|
||||
🇨🇳 <a href="./README.zh-CN.md">查看中文版介绍</a>
|
||||
|
||||
- 提供丰富的命令,涵盖从开发测试到构建发布的完整流程
|
||||
- 基于约定的目录结构,自动生成优雅的文档站点和组件示例
|
||||
- 内置 ESlint、Stylelint 校验规则,提交代码时自动执行校验
|
||||
- 构建后的组件库默认支持按需引入、主题定制、Tree Shaking
|
||||
---
|
||||
|
||||
### 快速上手
|
||||
### Features
|
||||
|
||||
执行以下命令可以快速创建一个基于 Vant Cli 的项目:
|
||||
- Provides rich commands covering the complete process from development to deploy
|
||||
- Based on conventional directory structure. Generate elegant document website and component examples automatically.
|
||||
- ESlint built-in.
|
||||
- Support Tree Shaking/Theme Customization/Import on Demand
|
||||
|
||||
### Quickstart
|
||||
|
||||
To create a Vant CLI project, run:
|
||||
|
||||
```bash
|
||||
yarn create vant-cli-app
|
||||
```
|
||||
|
||||
### 手动安装
|
||||
### Install Manually
|
||||
|
||||
```shell
|
||||
# 通过 npm
|
||||
# via npm
|
||||
npm i @vant/cli -D
|
||||
|
||||
# 通过 yarn
|
||||
# via yarn
|
||||
yarn add @vant/cli -D
|
||||
|
||||
# 通过 pnpm
|
||||
# via pnpm
|
||||
pnpm add @vant/cli -D
|
||||
```
|
||||
|
||||
安装完成后,请将以下配置添加到 package.json 文件中
|
||||
Please add the followed config to `package.json` file.
|
||||
|
||||
```json
|
||||
{
|
||||
@ -43,19 +47,15 @@ pnpm add @vant/cli -D
|
||||
"release": "vant-cli release",
|
||||
"build-site": "vant-cli build-site"
|
||||
},
|
||||
"lint-staged": {
|
||||
"nano-staged": {
|
||||
"*.md": "prettier --write",
|
||||
"*.{ts,tsx,js,vue,less,scss}": "prettier --write",
|
||||
"*.{ts,tsx,js,vue}": "eslint --fix",
|
||||
"*.{vue,css,less,scss}": "stylelint --fix"
|
||||
"*.{ts,tsx,js,vue}": "eslint --fix"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
"extends": ["@vant"]
|
||||
},
|
||||
"stylelint": {
|
||||
"extends": ["@vant/stylelint-config"]
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true
|
||||
},
|
||||
@ -63,9 +63,9 @@ pnpm add @vant/cli -D
|
||||
}
|
||||
```
|
||||
|
||||
## 详细文档
|
||||
## More Details
|
||||
|
||||
- [命令](https://github.com/youzan/vant/tree/dev/packages/vant-cli/docs/commands.md)
|
||||
- [配置指南](https://github.com/youzan/vant/tree/dev/packages/vant-cli/docs/config.md)
|
||||
- [目录结构](https://github.com/youzan/vant/tree/dev/packages/vant-cli/docs/directory.md)
|
||||
- [更新日志](https://github.com/youzan/vant/tree/dev/packages/vant-cli/changelog.md)
|
||||
- [cli](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/commands.md)
|
||||
- [config](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/config.md)
|
||||
- [directory structure](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/directory.md)
|
||||
- [CHANGELOG](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/changelog.md)
|
||||
|
||||
68
packages/vant-cli/README.zh-CN.md
Normal file
68
packages/vant-cli/README.zh-CN.md
Normal file
@ -0,0 +1,68 @@
|
||||
# Vant CLI
|
||||
|
||||
Vant CLI 是一个基于 Vite 实现的 Vue 组件库构建工具,通过 Vant CLI 可以快速搭建一套功能完备的 Vue 组件库。
|
||||
|
||||
### 特性
|
||||
|
||||
- 基于 Vite 实现,享受愉悦的开发体验
|
||||
- 提供丰富的命令,涵盖从开发测试到构建发布的完整流程
|
||||
- 基于约定的目录结构,自动生成优雅的文档站点和组件示例
|
||||
- 内置 ESLint 校验规则,提交代码时自动执行校验
|
||||
- 构建后的组件库默认支持按需引入、主题定制、Tree Shaking
|
||||
|
||||
### 快速上手
|
||||
|
||||
执行以下命令可以快速创建一个基于 Vant CLI 的项目:
|
||||
|
||||
```bash
|
||||
yarn create vant-cli-app
|
||||
```
|
||||
|
||||
### 手动安装
|
||||
|
||||
```shell
|
||||
# 通过 npm
|
||||
npm i @vant/cli -D
|
||||
|
||||
# 通过 yarn
|
||||
yarn add @vant/cli -D
|
||||
|
||||
# 通过 pnpm
|
||||
pnpm add @vant/cli -D
|
||||
```
|
||||
|
||||
安装完成后,请将以下配置添加到 package.json 文件中
|
||||
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"dev": "vant-cli dev",
|
||||
"test": "vant-cli test",
|
||||
"lint": "vant-cli lint",
|
||||
"build": "vant-cli build",
|
||||
"prepare": "husky install",
|
||||
"release": "vant-cli release",
|
||||
"build-site": "vant-cli build-site"
|
||||
},
|
||||
"nano-staged": {
|
||||
"*.md": "prettier --write",
|
||||
"*.{ts,tsx,js,vue,less,scss}": "prettier --write",
|
||||
"*.{ts,tsx,js,vue}": "eslint --fix"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
"extends": ["@vant"]
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true
|
||||
},
|
||||
"browserslist": ["Chrome >= 51", "iOS >= 10"]
|
||||
}
|
||||
```
|
||||
|
||||
## 详细文档
|
||||
|
||||
- [命令](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/commands.zh-CN.md)
|
||||
- [配置指南](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/config.zh-CN.md)
|
||||
- [目录结构](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/directory.zh-CN.md)
|
||||
- [更新日志](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/changelog.md)
|
||||
@ -1,5 +1,66 @@
|
||||
# 更新日志
|
||||
|
||||
## v5.0.0 (未发布)
|
||||
|
||||
### 依赖升级
|
||||
|
||||
对以下依赖进行了大版本升级:
|
||||
|
||||
- vite v3
|
||||
- @vitejs/plugin-vue v3
|
||||
- @vitejs/plugin-vue-jsx v2
|
||||
|
||||
### 依赖精简
|
||||
|
||||
- 不再默认安装 `gh-pages` 依赖,请按照如下方式更新 `package.json`:
|
||||
|
||||
```diff
|
||||
- "release:site": "pnpm build:site && gh-pages -d site-dist",
|
||||
+ "release:site": "pnpm build:site && npx gh-pages -d site-dist",
|
||||
```
|
||||
|
||||
- 不再默认内置 `stylelint`,需要的话可以自行安装:
|
||||
|
||||
```bash
|
||||
yarn add stylelint@13 @vant/stylelint-config
|
||||
```
|
||||
|
||||
### 移除 vetur 相关配置
|
||||
|
||||
由于 Vue 3 推荐使用 volar 而不是 vetur,因此移除了 vetur 相关的配置文件。
|
||||
|
||||
现在会默认生成 WebStorm 所需的 web-types.json 文件到 `lib/web-types.json` 目录下。
|
||||
|
||||
## v4.0.4
|
||||
|
||||
`2022-07-02`
|
||||
|
||||
- 修复构建 sfc 文件的类型定义时报错的问题
|
||||
|
||||
## v4.0.3
|
||||
|
||||
`2022-07-02`
|
||||
|
||||
- 新增 `build.bundleOptions` 配置项
|
||||
- 新增 `css.removeSourceFile` 配置项
|
||||
- 修复编译后的 script setup 中,引用的组件不生效的问题
|
||||
- 移除未使用的 esm bundle
|
||||
- 移除未使用的 ssr.js 文件
|
||||
|
||||
## v4.0.2
|
||||
|
||||
`2022-05-14`
|
||||
|
||||
- 修复编译 script setup 错误的问题
|
||||
|
||||
## v4.0.1
|
||||
|
||||
`2022-03-03`
|
||||
|
||||
- 支持复制示例代码到剪贴板
|
||||
- 修复官网更新日志的版本链接及 issue 链接异常的问题
|
||||
- 修复 ReDoS 安全问题
|
||||
|
||||
## v4.0.0
|
||||
|
||||
`2022-02-07`
|
||||
@ -10,7 +71,7 @@
|
||||
- 使用 vite 代替 webpack 进行构建,移除了所有 webpack 相关依赖
|
||||
- 使用 esbuild 进行代码转义和压缩
|
||||
- babel preset 添加了 `cjs` 后缀,现在需要通过 `@vant/cli/preset.cjs` 引入
|
||||
- vant.config.js 重命名为 `vant.config.mjs`,由 commonJs 变更为 ESModule 格式
|
||||
- vant.config.js 重命名为 `vant.config.mjs`,由 CommonJS 变更为 ESModule 格式
|
||||
- 站点构建产物的目录由 `site` 调整为 `site-dist`
|
||||
- 不再支持 webpack.config.js 配置文件
|
||||
- 不再支持 less import 语法中使用波浪号
|
||||
@ -382,15 +443,15 @@ yarn add sass
|
||||
|
||||
`2020-03-29`
|
||||
|
||||
- 优化网站导航栏在大屏上的适配 ([#5928](https://github.com/youzan/vant/pull/5928))
|
||||
- 优化网站导航栏在大屏上的适配 ([#5928](https://github.com/vant-ui/vant/pull/5928))
|
||||
|
||||
### v2.3.0
|
||||
|
||||
`2020-03-25`
|
||||
|
||||
- build 命令支持编译 scoped 样式 ([#5910](https://github.com/youzan/vant/pull/5910))
|
||||
- build 命令支持生成 WebStorm 组件定义文件 ([#5899](https://github.com/youzan/vant/issues/5899))
|
||||
- clean 命令现在会移除而不是清空文件夹 ([#5895](https://github.com/youzan/vant/issues/5895))
|
||||
- build 命令支持编译 scoped 样式 ([#5910](https://github.com/vant-ui/vant/pull/5910))
|
||||
- build 命令支持生成 WebStorm 组件定义文件 ([#5899](https://github.com/vant-ui/vant/issues/5899))
|
||||
- clean 命令现在会移除而不是清空文件夹 ([#5895](https://github.com/vant-ui/vant/issues/5895))
|
||||
- 升级 @vant/markdown-vetur 2.0.0
|
||||
|
||||
### v2.2.8
|
||||
@ -424,7 +485,7 @@ yarn add sass
|
||||
|
||||
`2020-02-14`
|
||||
|
||||
- 修复在 windows 上构建出的样式入口文件路径错误的问题 ([#5655](https://github.com/youzan/vant/pull/5655)
|
||||
- 修复在 windows 上构建出的样式入口文件路径错误的问题 ([#5655](https://github.com/vant-ui/vant/pull/5655)
|
||||
|
||||
### v2.2.3
|
||||
|
||||
@ -436,14 +497,14 @@ yarn add sass
|
||||
|
||||
`2020-02-05`
|
||||
|
||||
- 修复在 windows 上获取 markdown 路径错误的问题 ([#5626](https://github.com/youzan/vant/pull/5626))
|
||||
- 修复在 windows 上获取 markdown 路径错误的问题 ([#5626](https://github.com/vant-ui/vant/pull/5626))
|
||||
|
||||
### v2.2.1
|
||||
|
||||
`2020-02-04`
|
||||
|
||||
- 升级 babel@7.8
|
||||
- 修复切换版本时跳转 undefined 的问题 ([#5620](https://github.com/youzan/vant/pull/5620))
|
||||
- 修复切换版本时跳转 undefined 的问题 ([#5620](https://github.com/vant-ui/vant/pull/5620))
|
||||
|
||||
### v2.2.0
|
||||
|
||||
@ -471,7 +532,7 @@ yarn add sass
|
||||
|
||||
`2020-01-12`
|
||||
|
||||
- 支持自定义 Postcss 配置
|
||||
- 支持自定义 PostCSS 配置
|
||||
- 支持自定义 devServer 端口
|
||||
- 优化文档站点的 meta 字段
|
||||
- 新增 API 文档中的版本标签样式
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# 命令
|
||||
# Commands
|
||||
|
||||
Vant Cli 中内置了一系列的命令,可以将命令添加到 npm scripts 中进行使用。
|
||||
You can add built-in commands to `npm scripts` to use it.
|
||||
|
||||
```json
|
||||
// package.json
|
||||
@ -15,7 +15,7 @@ Vant Cli 中内置了一系列的命令,可以将命令添加到 npm scripts
|
||||
}
|
||||
```
|
||||
|
||||
也可以通过 npm 自带的 [npx](https://github.com/npm/npx) 直接执行某个命令:
|
||||
Additionally, [npx](https://github.com/npm/npx) can used to be run those commands.
|
||||
|
||||
```bash
|
||||
npx vant-cli dev
|
||||
@ -23,17 +23,15 @@ npx vant-cli dev
|
||||
|
||||
### dev
|
||||
|
||||
运行本地开发环境。
|
||||
|
||||
运行 dev 命令时,Vant Cli 会通过启动一个本地服务器,用于在开发过程中对文档和示例进行预览。
|
||||
Start local dev server for browsering components and demo.
|
||||
|
||||
### build
|
||||
|
||||
构建组件库。
|
||||
Build Vue component library.
|
||||
|
||||
运行 build 命令会在 `es` 和 `lib` 目录下生成可用于生产环境的组件代码,详见 [目录结构](https://github.com/youzan/vant/tree/dev/packages/vant-cli/docs/directory.md)。
|
||||
Files will be output to `es` and `lib` directory. More details [directory structure](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/directory.md)
|
||||
|
||||
发布 npm 时,请将以下配置加入到 `package.json` 中,使 npm 包能被正确识别:
|
||||
Please add the followed config to `package.json` when publish to npm.
|
||||
|
||||
```json
|
||||
// package.json
|
||||
@ -46,19 +44,19 @@ npx vant-cli dev
|
||||
|
||||
### build-site
|
||||
|
||||
构建文档站点,在 `site` 目录生成可用于生产环境的文档站点代码。
|
||||
Build documentation website. Files will be output to `site` directory.
|
||||
|
||||
### release
|
||||
|
||||
发布组件库,发布前会自动执行 build 和 changelog 命令,并通过 [release-it](https://github.com/release-it/release-it) 发布 npm 包。
|
||||
Publish to npm. `build` and `changelog` will be automatically execute when run `release`.
|
||||
|
||||
## changelog
|
||||
### changelog
|
||||
|
||||
基于 commit 记录生成更新日志,基于 [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) 实现。
|
||||
Generate changelog based on commit records.
|
||||
|
||||
## commit-lint
|
||||
### commit-lint
|
||||
|
||||
校验 commit message 的格式是否符合规范,需要配合 `husky` 在提交 commit 时触发。
|
||||
Validate the format of commit message. Need `husky` to do this.
|
||||
|
||||
```bash
|
||||
npx husky add .husky/commit-msg 'npx --no-install vant-cli commit-lint $1'
|
||||
|
||||
65
packages/vant-cli/docs/commands.zh-CN.md
Normal file
65
packages/vant-cli/docs/commands.zh-CN.md
Normal file
@ -0,0 +1,65 @@
|
||||
# 命令
|
||||
|
||||
Vant CLI 中内置了一系列的命令,可以将命令添加到 npm scripts 中进行使用。
|
||||
|
||||
```json
|
||||
// package.json
|
||||
{
|
||||
"scripts": {
|
||||
"dev": "vant-cli dev",
|
||||
"test": "vant-cli test",
|
||||
"lint": "vant-cli lint",
|
||||
"release": "vant-cli release",
|
||||
"build-site": "vant-cli build-site"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
也可以通过 npm 自带的 [npx](https://github.com/npm/npx) 直接执行某个命令:
|
||||
|
||||
```bash
|
||||
npx vant-cli dev
|
||||
```
|
||||
|
||||
### dev
|
||||
|
||||
运行本地开发环境。
|
||||
|
||||
运行 dev 命令时,Vant CLI 会通过启动一个本地服务器,用于在开发过程中对文档和示例进行预览。
|
||||
|
||||
### build
|
||||
|
||||
构建组件库。
|
||||
|
||||
运行 build 命令会在 `es` 和 `lib` 目录下生成可用于生产环境的组件代码,详见 [目录结构](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/directory.zh-CN.md)。
|
||||
|
||||
发布 npm 时,请将以下配置加入到 `package.json` 中,使 npm 包能被正确识别:
|
||||
|
||||
```json
|
||||
// package.json
|
||||
{
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
"files": ["es", "lib"]
|
||||
}
|
||||
```
|
||||
|
||||
### build-site
|
||||
|
||||
构建文档站点,在 `site` 目录生成可用于生产环境的文档站点代码。
|
||||
|
||||
### release
|
||||
|
||||
发布组件库,发布前会自动执行 build 和 changelog 命令,并通过 [release-it](https://github.com/release-it/release-it) 发布 npm 包。
|
||||
|
||||
### changelog
|
||||
|
||||
基于 commit 记录生成更新日志,基于 [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) 实现。
|
||||
|
||||
### commit-lint
|
||||
|
||||
校验 commit message 的格式是否符合规范,需要配合 `husky` 在提交 commit 时触发。
|
||||
|
||||
```bash
|
||||
npx husky add .husky/commit-msg 'npx --no-install vant-cli commit-lint $1'
|
||||
```
|
||||
@ -1,6 +1,6 @@
|
||||
# 配置指南
|
||||
# Config
|
||||
|
||||
- [配置指南](#----)
|
||||
- [Config](#----)
|
||||
- [vant.config.mjs](#vantconfigmjs)
|
||||
- [name](#name)
|
||||
- [build.css.base](#buildcssbase)
|
||||
@ -21,49 +21,49 @@
|
||||
- [site.simulator.url](#sitesimulatorurl)
|
||||
- [site.htmlMeta](#sitehtmlmeta)
|
||||
- [site.enableVConsole](#siteenablevconsole)
|
||||
- [Postcss](#postcss)
|
||||
- [默认配置](#-----1)
|
||||
- [PostCSS](#postcss)
|
||||
- [Default Config](#-----1)
|
||||
- [browserslist](#browserslist)
|
||||
|
||||
## vant.config.mjs
|
||||
|
||||
`vant.config.mjs` 中包含了 `vant-cli` 的打包配置和文档站点配置,请创建此文件并置于项目根目录下。下面是一份基本配置的示例:
|
||||
`vant.config.mjs` includes bundle and documentation site config. Please create this file and place it in your project root directory. Here is a basic example:
|
||||
|
||||
```js
|
||||
export default {
|
||||
// 组件库名称
|
||||
// component library name
|
||||
name: 'demo-ui',
|
||||
// 构建配置
|
||||
// bundle config
|
||||
build: {
|
||||
site: {
|
||||
publicPath: '/demo-ui/',
|
||||
},
|
||||
},
|
||||
// 文档站点配置
|
||||
// documentation site config
|
||||
site: {
|
||||
// 标题
|
||||
// title
|
||||
title: 'Demo UI',
|
||||
// 图标
|
||||
logo: 'https://img.yzcdn.cn/vant/logo.png',
|
||||
// 描述
|
||||
// logo
|
||||
logo: 'https://fastly.jsdelivr.net/npm/@vant/assets/logo.png',
|
||||
// description
|
||||
description: '示例组件库',
|
||||
// 左侧导航
|
||||
// left nav
|
||||
nav: [
|
||||
{
|
||||
title: '开发指南',
|
||||
title: 'example',
|
||||
items: [
|
||||
{
|
||||
path: 'home',
|
||||
title: '介绍',
|
||||
title: 'home',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '基础组件',
|
||||
title: 'basic components',
|
||||
items: [
|
||||
{
|
||||
path: 'my-button',
|
||||
title: 'MyButton 按钮',
|
||||
title: 'MyButton',
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -77,16 +77,16 @@ export default {
|
||||
- Type: `string`
|
||||
- Default: `''`
|
||||
|
||||
组件库名称,建议使用中划线分割,如 `demo-ui`。
|
||||
Component library name. kebab-case recommended.
|
||||
|
||||
### build.css.base
|
||||
|
||||
- Type: `string`
|
||||
- Default: `'style/base.less'`
|
||||
|
||||
全局样式文件的路径,可以为相对路径或绝对路径。
|
||||
Global style file path. Support absolute path and relative path both.
|
||||
|
||||
相对路径基于 `src` 目录计算。
|
||||
Note: relative path is calculated based on `src`.
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
@ -103,7 +103,7 @@ module.exports = {
|
||||
- Type: `string`
|
||||
- Default: `'less'`
|
||||
|
||||
CSS 预处理器配置,目前支持 `less` 和 `sass` 两种预处理器,默认使用 `less`。
|
||||
CSS preprocessor config, support `less` and `sass`. Use `less` by default.
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
@ -115,14 +115,31 @@ module.exports = {
|
||||
};
|
||||
```
|
||||
|
||||
### build.css.removeSourceFile
|
||||
|
||||
- Type: `boolean`
|
||||
- Default: `'false'`
|
||||
|
||||
Whether to remove the source style files after build.
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
build: {
|
||||
css: {
|
||||
removeSourceFile: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### build.site.publicPath
|
||||
|
||||
- Type: `string`
|
||||
- Default: `/`
|
||||
|
||||
等价于 vite 的 `build.outDir` 配置。
|
||||
Equivalent to vite `build.outDir`.
|
||||
|
||||
一般来说,我们的文档网站会部署在一个域名的子路径上,如 `https://my.github.io/demo-ui/`,这时候 `publicPath` 需要跟子路径保持一致,即 `/demo-ui/`。
|
||||
Generally, documentation site will be deployed to subpath of domain. For example: `https://my.github.io/demo-ui/`, `publicPath` should be `/demo-ui/`.
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
@ -152,24 +169,24 @@ module.exports = {
|
||||
- Type: `boolean`
|
||||
- Default: `false`
|
||||
|
||||
是否通过 Named Export 对组件进行导出。
|
||||
Should export components by Named Export.
|
||||
|
||||
未开启此选项时,会通过 `export default from 'xxx'` 导出组件内部的默认模块。
|
||||
When set to `false`, `export default from 'xxx'` will be used to export module.
|
||||
|
||||
开启此选项后,会通过 `export * from 'xxx'` 导出组件内部的所有模块、类型定义。
|
||||
When set to `true`, `export * from 'xxx'` will be used to export all modules and type definition.
|
||||
|
||||
### build.configureVite
|
||||
|
||||
- Type: `(config: InlineConfig): InlineConfig`
|
||||
- Default: `undefined`
|
||||
|
||||
vant-cli 使用 vite 来构建组件库和文档站点,通过 `configureVite` 选项可以自定义 vite 配置(从 4.0.0 版本开始支持)。
|
||||
Custom vite config(`@vant/cli>= 4.0.0`)
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
build: {
|
||||
configureVite(config) {
|
||||
// 添加一个自定义插件
|
||||
// add vite plugin
|
||||
config.plugins.push(vitePluginXXX);
|
||||
return config;
|
||||
},
|
||||
@ -177,8 +194,6 @@ module.exports = {
|
||||
};
|
||||
```
|
||||
|
||||
在自定义配置时,可以通过 `process.env.BUILD_TARGET` 对构建目标进行区分:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
build: {
|
||||
@ -186,11 +201,11 @@ module.exports = {
|
||||
const { BUILD_TARGET } = process.env;
|
||||
|
||||
if (BUILD_TARGET === 'package') {
|
||||
// 修改组件库构建配置
|
||||
// component library bundle config
|
||||
}
|
||||
|
||||
if (BUILD_TARGET === 'site') {
|
||||
// 修改文档站点构建配置
|
||||
// documentation site bundle config
|
||||
}
|
||||
|
||||
return config;
|
||||
@ -204,51 +219,90 @@ module.exports = {
|
||||
- Type: `'npm' | 'yarn' | 'pnpm'`
|
||||
- Default: `undefined`
|
||||
|
||||
指定使用的包管理器。
|
||||
`npm` package manager.
|
||||
|
||||
### build.bundleOptions
|
||||
|
||||
- Type: `BundleOptions[]`
|
||||
|
||||
Specify the format of the bundled output.
|
||||
|
||||
The type of `BundleOptions`:
|
||||
|
||||
```ts
|
||||
type BundleOption = {
|
||||
// Whether to minify code (Tips: es format output can't be minified by vite)
|
||||
minify?: boolean;
|
||||
// Formats, can be set to 'es' | 'cjs' | 'umd' | 'iife'
|
||||
formats: LibraryFormats[];
|
||||
// Dependencies to external (Vue is externaled by default)
|
||||
external?: string[];
|
||||
};
|
||||
```
|
||||
|
||||
Default value:
|
||||
|
||||
```ts
|
||||
const DEFAULT_OPTIONS: BundleOption[] = [
|
||||
{
|
||||
minify: false,
|
||||
formats: ['umd'],
|
||||
},
|
||||
{
|
||||
minify: true,
|
||||
formats: ['umd'],
|
||||
},
|
||||
{
|
||||
minify: false,
|
||||
formats: ['es', 'cjs'],
|
||||
external: allDependencies,
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
### site.title
|
||||
|
||||
- Type: `string`
|
||||
- Default: `''`
|
||||
|
||||
文档站点的标题。
|
||||
Documentation site title.
|
||||
|
||||
### site.logo
|
||||
|
||||
- Type: `string`
|
||||
- Default: `''`
|
||||
|
||||
文档站点的 Logo。
|
||||
Documentation site logo.
|
||||
|
||||
### site.description
|
||||
|
||||
- Type: `string`
|
||||
- Default: `''`
|
||||
|
||||
标题下方的描述文案。
|
||||
Documentation site description.
|
||||
|
||||
### site.nav
|
||||
|
||||
- Type: `object[]`
|
||||
- Default: `undefined`
|
||||
|
||||
文档站点的左侧导航,数组中的每个对象表示一个导航分组。
|
||||
Documentation site left nav. Each item of `nav` means a navigation group.
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
site: {
|
||||
nav: [
|
||||
{
|
||||
// 分组标题
|
||||
title: '开发指南',
|
||||
// 导航项
|
||||
// group title
|
||||
title: 'Development Guide',
|
||||
// nav items
|
||||
items: [
|
||||
{
|
||||
// 导航项路由
|
||||
// nav router
|
||||
path: 'home',
|
||||
// 导航项文案
|
||||
title: '介绍',
|
||||
// 是否隐藏当前页右侧的手机模拟器(默认不隐藏)
|
||||
// nav title
|
||||
title: 'title',
|
||||
// should hide phone emulator(false by default)
|
||||
hideSimulator: true,
|
||||
},
|
||||
],
|
||||
@ -263,7 +317,7 @@ module.exports = {
|
||||
- Type: `object[]`
|
||||
- Default: `undefined`
|
||||
|
||||
文档站点多版本配置,当组件库存在多个版本的文档时,可以通过`site.versions`在顶部导航配置一个版本切换按钮。
|
||||
Documentation site muti-version config.
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
@ -271,7 +325,7 @@ module.exports = {
|
||||
versions: [
|
||||
{
|
||||
label: 'v1',
|
||||
link: 'https://youzan.github.io/vant/v1/',
|
||||
link: 'https://vant-ui.github.io/vant/v1/',
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -281,17 +335,17 @@ module.exports = {
|
||||
### site.baiduAnalytics
|
||||
|
||||
- Type: `object`
|
||||
- Default: `undefied`
|
||||
- Default: `undefined`
|
||||
|
||||
文档网站的百度统计配置,添加这项配置后,会自动在构建文档网站时加载百度统计的脚本。
|
||||
Documentation site baidu analysis config. The script of Baidu Statistic will be automatically loaded when build documentation website.
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
site: {
|
||||
baiduAnalytics: {
|
||||
// 打开百度统计 ->『管理』->『代码获取』
|
||||
// 找到下面这串 URL: "https://hm.baidu.com/hm.js?xxxxx"
|
||||
// 将 `xxxxx` 填写在 seed 中即可
|
||||
// find the followed URL: "https://hm.baidu.com/hm.js?xxxxx"
|
||||
// add `xxxxx` in the seed
|
||||
seed: 'xxxxx',
|
||||
},
|
||||
},
|
||||
@ -303,45 +357,50 @@ module.exports = {
|
||||
- Type: `object`
|
||||
- Default: `undefined`
|
||||
|
||||
文档网站的搜索配置,基于 algolia 提供的 docsearch 服务实现。
|
||||
|
||||
配置内容参见 [docsearch](https://docsearch.algolia.com/docs/behavior)。
|
||||
Documentation site search config. Based on [docsearch](https://docsearch.algolia.com/docs/behavior) of algolia.
|
||||
|
||||
### site.hideSimulator
|
||||
|
||||
- Type: `boolean`
|
||||
- Default: `false`
|
||||
|
||||
是否隐藏所有页面右侧的手机模拟器,默认不隐藏
|
||||
Should hide phone emulator, `false` by default.
|
||||
|
||||
### site.simulator.url
|
||||
|
||||
- Type: `string`
|
||||
- Default: -
|
||||
|
||||
自定义手机模拟器的 iframe URL 地址。
|
||||
Customize iframe URL.
|
||||
|
||||
### site.htmlMeta
|
||||
|
||||
- Type: `Record<string, string>`
|
||||
- Default: `undefined`
|
||||
|
||||
配置 HTML 中的 meta 标签,对象的 key 为 name,value 为 content。
|
||||
Customize HTML meta tag, key means name, value means content.
|
||||
|
||||
### site.headHtml
|
||||
|
||||
- Type: `string`
|
||||
- Default: `undefined`
|
||||
|
||||
Insert a custom HTML content in the `<head>` tag.
|
||||
|
||||
### site.enableVConsole
|
||||
|
||||
- Type: `boolean`
|
||||
- Default: `false`
|
||||
|
||||
是否在 dev 时开启 [vConsole](https://github.com/Tencent/vConsole) 调试,用于移动端 debug。
|
||||
Whether to enable [vConsole](https://github.com/Tencent/vConsole) debugging in dev, usually used for mobile debugging.
|
||||
|
||||
## Postcss
|
||||
## PostCSS
|
||||
|
||||
通过根目录下的`postcss.config.js`文件可以对 Postcss 进行配置。
|
||||
PostCSS can be configured through the `postcss.config.js` file in the root directory.
|
||||
|
||||
### 默认配置
|
||||
### Default Config
|
||||
|
||||
`vant-cli` 中默认的 Postcss 配置如下:
|
||||
PostCSS default config:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
@ -353,9 +412,9 @@ module.exports = {
|
||||
|
||||
## browserslist
|
||||
|
||||
推荐在 `package.json` 文件里添加 browserslist 字段,这个值会被 `autoprefixer` 用来确定目标浏览器的版本,保证编译后代码的兼容性。
|
||||
Add browserslist field to `package.json` file is recommended. It's used by `autoprefixer` to determine the version of target browser, ensuring compatibility of compiled code.
|
||||
|
||||
在移动端浏览器中使用,可以添加如下配置:
|
||||
You can add the following config for mobile:
|
||||
|
||||
```json
|
||||
{
|
||||
|
||||
427
packages/vant-cli/docs/config.zh-CN.md
Normal file
427
packages/vant-cli/docs/config.zh-CN.md
Normal file
@ -0,0 +1,427 @@
|
||||
# 配置指南
|
||||
|
||||
- [配置指南](#----)
|
||||
- [vant.config.mjs](#vantconfigmjs)
|
||||
- [name](#name)
|
||||
- [build.css.base](#buildcssbase)
|
||||
- [build.css.preprocessor](#buildcsspreprocessor)
|
||||
- [build.site.publicPath](#buildsitepublicpath)
|
||||
- [build.srcDir](#buildsrcdir)
|
||||
- [build.namedExport](#buildnamedexport)
|
||||
- [build.configureVite](#buildconfigurevite)
|
||||
- [build.packageManager](#buildpackagemanager)
|
||||
- [site.title](#sitetitle)
|
||||
- [site.logo](#sitelogo)
|
||||
- [site.description](#sitedescription)
|
||||
- [site.nav](#sitenav)
|
||||
- [site.versions](#siteversions)
|
||||
- [site.baiduAnalytics](#sitebaiduanalytics)
|
||||
- [site.searchConfig](#sitesearchconfig)
|
||||
- [site.hideSimulator](#sitehidesimulator)
|
||||
- [site.simulator.url](#sitesimulatorurl)
|
||||
- [site.htmlMeta](#sitehtmlmeta)
|
||||
- [site.enableVConsole](#siteenablevconsole)
|
||||
- [PostCSS](#postcss)
|
||||
- [默认配置](#-----1)
|
||||
- [browserslist](#browserslist)
|
||||
|
||||
## vant.config.mjs
|
||||
|
||||
`vant.config.mjs` 中包含了 `vant-cli` 的打包配置和文档站点配置,请创建此文件并置于项目根目录下。下面是一份基本配置的示例:
|
||||
|
||||
```js
|
||||
export default {
|
||||
// 组件库名称
|
||||
name: 'demo-ui',
|
||||
// 构建配置
|
||||
build: {
|
||||
site: {
|
||||
publicPath: '/demo-ui/',
|
||||
},
|
||||
},
|
||||
// 文档站点配置
|
||||
site: {
|
||||
// 标题
|
||||
title: 'Demo UI',
|
||||
// 图标
|
||||
logo: 'https://fastly.jsdelivr.net/npm/@vant/assets/logo.png',
|
||||
// 描述
|
||||
description: '示例组件库',
|
||||
// 左侧导航
|
||||
nav: [
|
||||
{
|
||||
title: '开发指南',
|
||||
items: [
|
||||
{
|
||||
path: 'home',
|
||||
title: '介绍',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '基础组件',
|
||||
items: [
|
||||
{
|
||||
path: 'my-button',
|
||||
title: 'MyButton 按钮',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### name
|
||||
|
||||
- Type: `string`
|
||||
- Default: `''`
|
||||
|
||||
组件库名称,建议使用中划线分割,如 `demo-ui`。
|
||||
|
||||
### build.css.base
|
||||
|
||||
- Type: `string`
|
||||
- Default: `'style/base.less'`
|
||||
|
||||
全局样式文件的路径,可以为相对路径或绝对路径。
|
||||
|
||||
相对路径基于 `src` 目录计算。
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
build: {
|
||||
css: {
|
||||
base: 'style/global.scss',
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### build.css.preprocessor
|
||||
|
||||
- Type: `string`
|
||||
- Default: `'less'`
|
||||
|
||||
CSS 预处理器配置,目前支持 `less` 和 `sass` 两种预处理器,默认使用 `less`。
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
build: {
|
||||
css: {
|
||||
preprocessor: 'sass',
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### build.css.removeSourceFile
|
||||
|
||||
- Type: `boolean`
|
||||
- Default: `'false'`
|
||||
|
||||
是否在构建后移除样式文件的源代码。
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
build: {
|
||||
css: {
|
||||
removeSourceFile: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### build.site.publicPath
|
||||
|
||||
- Type: `string`
|
||||
- Default: `/`
|
||||
|
||||
等价于 vite 的 `build.outDir` 配置。
|
||||
|
||||
一般来说,我们的文档网站会部署在一个域名的子路径上,如 `https://my.github.io/demo-ui/`,这时候 `publicPath` 需要跟子路径保持一致,即 `/demo-ui/`。
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
build: {
|
||||
site: {
|
||||
publicPath: '/demo-ui/',
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### build.srcDir
|
||||
|
||||
- Type: `string`
|
||||
- Default: `src`
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
build: {
|
||||
srcDir: 'myDir',
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### build.namedExport
|
||||
|
||||
- Type: `boolean`
|
||||
- Default: `false`
|
||||
|
||||
是否通过 Named Export 对组件进行导出。
|
||||
|
||||
未开启此选项时,会通过 `export default from 'xxx'` 导出组件内部的默认模块。
|
||||
|
||||
开启此选项后,会通过 `export * from 'xxx'` 导出组件内部的所有模块、类型定义。
|
||||
|
||||
### build.configureVite
|
||||
|
||||
- Type: `(config: InlineConfig): InlineConfig`
|
||||
- Default: `undefined`
|
||||
|
||||
vant-cli 使用 vite 来构建组件库和文档站点,通过 `configureVite` 选项可以自定义 vite 配置(从 4.0.0 版本开始支持)。
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
build: {
|
||||
configureVite(config) {
|
||||
// 添加一个自定义插件
|
||||
config.plugins.push(vitePluginXXX);
|
||||
return config;
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
在自定义配置时,可以通过 `process.env.BUILD_TARGET` 对构建目标进行区分:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
build: {
|
||||
configureVite(config) {
|
||||
const { BUILD_TARGET } = process.env;
|
||||
|
||||
if (BUILD_TARGET === 'package') {
|
||||
// 修改组件库构建配置
|
||||
}
|
||||
|
||||
if (BUILD_TARGET === 'site') {
|
||||
// 修改文档站点构建配置
|
||||
}
|
||||
|
||||
return config;
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### build.packageManager
|
||||
|
||||
- Type: `'npm' | 'yarn' | 'pnpm'`
|
||||
- Default: `undefined`
|
||||
|
||||
指定使用的包管理器。
|
||||
|
||||
### build.bundleOptions
|
||||
|
||||
- Type: `BundleOptions[]`
|
||||
|
||||
指定打包后产物的格式。
|
||||
|
||||
产物格式由三个配置项控制:
|
||||
|
||||
```ts
|
||||
type BundleOption = {
|
||||
// 是否压缩代码(注意 es 产物无法被 vite 压缩)
|
||||
minify?: boolean;
|
||||
// 产物类型,可选值为 'es' | 'cjs' | 'umd' | 'iife'
|
||||
formats: LibraryFormats[];
|
||||
// 需要 external 的依赖(Vue 默认会被 external)
|
||||
external?: string[];
|
||||
};
|
||||
```
|
||||
|
||||
该选项的默认值为:
|
||||
|
||||
```ts
|
||||
const DEFAULT_OPTIONS: BundleOption[] = [
|
||||
{
|
||||
minify: false,
|
||||
formats: ['umd'],
|
||||
},
|
||||
{
|
||||
minify: true,
|
||||
formats: ['umd'],
|
||||
},
|
||||
{
|
||||
minify: false,
|
||||
formats: ['es', 'cjs'],
|
||||
external: allDependencies,
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
### site.title
|
||||
|
||||
- Type: `string`
|
||||
- Default: `''`
|
||||
|
||||
文档站点的标题。
|
||||
|
||||
### site.logo
|
||||
|
||||
- Type: `string`
|
||||
- Default: `''`
|
||||
|
||||
文档站点的 Logo。
|
||||
|
||||
### site.description
|
||||
|
||||
- Type: `string`
|
||||
- Default: `''`
|
||||
|
||||
标题下方的描述文案。
|
||||
|
||||
### site.nav
|
||||
|
||||
- Type: `object[]`
|
||||
- Default: `undefined`
|
||||
|
||||
文档站点的左侧导航,数组中的每个对象表示一个导航分组。
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
site: {
|
||||
nav: [
|
||||
{
|
||||
// 分组标题
|
||||
title: '开发指南',
|
||||
// 导航项
|
||||
items: [
|
||||
{
|
||||
// 导航项路由
|
||||
path: 'home',
|
||||
// 导航项文案
|
||||
title: '介绍',
|
||||
// 是否隐藏当前页右侧的手机模拟器(默认不隐藏)
|
||||
hideSimulator: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### site.versions
|
||||
|
||||
- Type: `object[]`
|
||||
- Default: `undefined`
|
||||
|
||||
文档站点多版本配置,当组件库存在多个版本的文档时,可以通过`site.versions`在顶部导航配置一个版本切换按钮。
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
site: {
|
||||
versions: [
|
||||
{
|
||||
label: 'v1',
|
||||
link: 'https://vant-ui.github.io/vant/v1/',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### site.baiduAnalytics
|
||||
|
||||
- Type: `object`
|
||||
- Default: `undefined`
|
||||
|
||||
文档网站的百度统计配置,添加这项配置后,会自动在构建文档网站时加载百度统计的脚本。
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
site: {
|
||||
baiduAnalytics: {
|
||||
// 打开百度统计 ->『管理』->『代码获取』
|
||||
// 找到下面这串 URL: "https://hm.baidu.com/hm.js?xxxxx"
|
||||
// 将 `xxxxx` 填写在 seed 中即可
|
||||
seed: 'xxxxx',
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### site.searchConfig
|
||||
|
||||
- Type: `object`
|
||||
- Default: `undefined`
|
||||
|
||||
文档网站的搜索配置,基于 algolia 提供的 docsearch 服务实现。
|
||||
|
||||
配置内容参见 [docsearch](https://docsearch.algolia.com/docs/behavior)。
|
||||
|
||||
### site.hideSimulator
|
||||
|
||||
- Type: `boolean`
|
||||
- Default: `false`
|
||||
|
||||
是否隐藏所有页面右侧的手机模拟器,默认不隐藏
|
||||
|
||||
### site.simulator.url
|
||||
|
||||
- Type: `string`
|
||||
- Default: -
|
||||
|
||||
自定义手机模拟器的 iframe URL 地址。
|
||||
|
||||
### site.htmlMeta
|
||||
|
||||
- Type: `Record<string, string>`
|
||||
- Default: `undefined`
|
||||
|
||||
配置 HTML 中的 meta 标签,对象的 key 为 name,value 为 content。
|
||||
|
||||
### site.headHtml
|
||||
|
||||
- Type: `string`
|
||||
- Default: `undefined`
|
||||
|
||||
在 `<head>` 标签中插入一段自定义的 HTML 内容。
|
||||
|
||||
### site.enableVConsole
|
||||
|
||||
- Type: `boolean`
|
||||
- Default: `false`
|
||||
|
||||
是否在 dev 时开启 [vConsole](https://github.com/Tencent/vConsole) 调试,用于移动端 debug。
|
||||
|
||||
## PostCSS
|
||||
|
||||
通过根目录下的`postcss.config.js`文件可以对 PostCSS 进行配置。
|
||||
|
||||
### 默认配置
|
||||
|
||||
`vant-cli` 中默认的 PostCSS 配置如下:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
plugins: {
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
## browserslist
|
||||
|
||||
推荐在 `package.json` 文件里添加 browserslist 字段,这个值会被 `autoprefixer` 用来确定目标浏览器的版本,保证编译后代码的兼容性。
|
||||
|
||||
在移动端浏览器中使用,可以添加如下配置:
|
||||
|
||||
```json
|
||||
{
|
||||
"browserslist": ["Chrome >= 51", "iOS >= 10"]
|
||||
}
|
||||
```
|
||||
@ -1,91 +1,91 @@
|
||||
# 目录结构
|
||||
# Directory Structure
|
||||
|
||||
## 源代码目录
|
||||
## Source Code Directory
|
||||
|
||||
基于 Vant Cli 搭建的组件库的基本目录结构如下所示:
|
||||
The basic directory structure of the component library based on Vant CLI is as follows:
|
||||
|
||||
```
|
||||
project
|
||||
├─ src # 组件源代码
|
||||
│ ├─ button # button 组件源代码
|
||||
│ └─ dialog # dialog 组件源代码
|
||||
├─ src # component library source code
|
||||
│ ├─ button # button source code
|
||||
│ └─ dialog # dialog source code
|
||||
│
|
||||
├─ docs # 静态文档目录
|
||||
│ ├─ home.md # 文档首页
|
||||
│ └─ changelog.md # 更新日志
|
||||
├─ docs # static doc directory
|
||||
│ ├─ home.md # documentation site home
|
||||
│ └─ changelog.md # changelog
|
||||
│
|
||||
├─ vant.config.mjs # Vant Cli 配置文件
|
||||
├─ vant.config.mjs # Vant CLI config file
|
||||
├─ package.json
|
||||
└─ README.md
|
||||
```
|
||||
|
||||
单个组件的目录如下:
|
||||
The directories for individual components are as follows:
|
||||
|
||||
```
|
||||
button
|
||||
├─ demo # 示例目录
|
||||
│ └─ index.vue # 组件示例
|
||||
├─ index.vue # 组件源码
|
||||
└─ README.md # 组件文档
|
||||
├─ demo # component demo directory
|
||||
│ └─ index.vue # component demo
|
||||
├─ index.vue # component source code
|
||||
└─ README.md # component doc
|
||||
```
|
||||
|
||||
使用 .vue 文件编写组件时,编译后会生成对应的 JS 和 CSS 文件,且 JS 文件中会自动引入 CSS 文件。
|
||||
When writing SFC, the corresponding JS and CSS files will be generated after bundle process, and the CSS file will be automatically imported into the JS file.
|
||||
|
||||
如果需要将 JS 和 CSS 解耦,实现主题定制等功能,在编写代码时就要使用独立的 JS 和 CSS 文件,如下所示:
|
||||
If you need to separate JS and CSS to implement functions such as theme customization, you need to use separate JS and CSS files when writing code, as shown below:
|
||||
|
||||
```
|
||||
button
|
||||
├─ demo # 组件示例
|
||||
│ └─ index.vue # 组件示例入口
|
||||
├─ index.js # 组件入口
|
||||
├─ index.less # 组件样式,可以为 less 或 scss
|
||||
└─ README.md # 组件文档
|
||||
├─ demo # component demo directory
|
||||
│ └─ index.vue # component demo entry
|
||||
├─ index.js # component entry
|
||||
├─ index.less # component style,support scss and less
|
||||
└─ README.md # component doc
|
||||
```
|
||||
|
||||
采用这种目录结构时,组件的使用者需要分别引入 JS 和 CSS 文件,也可以通过 babel-plugin-import 自动引入样式。
|
||||
When using this directory structure, the developer of the component library needs to import the JS and CSS files respectively.
|
||||
|
||||
通过引入样式源文件(less 或 scss)并修改样式变量,可以实现主题定制功能。
|
||||
Theme customization can be achieved by importing style source files (less or scss) and modifying style variables.
|
||||
|
||||
## 构建结果目录
|
||||
## Output Directory
|
||||
|
||||
运行 build 命令会在 `es` 和 `lib` 目录下生成可用于生产环境的组件代码,结构如下:
|
||||
Running the `build` command will generate production code in the `es` and `lib` directories with the following structure:
|
||||
|
||||
```
|
||||
project
|
||||
├─ es # es 目录下的代码遵循 esmodule 规范
|
||||
│ ├─ button # button 组件编译后的代码目录
|
||||
│ ├─ dialog # dialog 组件编译后的代码目录
|
||||
│ └─ index.js # 引入所有组件的入口 (ESModule)
|
||||
├─ es # ESM Directory
|
||||
│ ├─ button # button component directory
|
||||
│ ├─ dialog # dialog component directory
|
||||
│ └─ index.js # All component files entry (ESModule)
|
||||
│
|
||||
└─ lib # lib 目录下的代码遵循 commonjs 规范
|
||||
├─ button # button 组件编译后的代码目录
|
||||
├─ dialog # dialog 组件编译后的代码目录
|
||||
├─ index.js # 引入所有组件的入口
|
||||
├─ index.less # 所有组件未编译的样式入口
|
||||
├─ index.css # 打包后的组件样式,用于 CDN 引入
|
||||
├─ [name].js # 打包后的组件脚本,UMD 格式
|
||||
├─ [name].es.js # 打包后的组件脚本,ESModule 格式
|
||||
├─ [name].min.js # 打包和压缩后的组件脚本,UMD 格式
|
||||
└─ [name].es.min.js # 打包和压缩后的组件脚本,ESModule 格式
|
||||
└─ lib # Commonjs directory
|
||||
├─ button # button component library
|
||||
├─ dialog # dialog component library
|
||||
├─ index.js # All component files entry (Commonjs)
|
||||
├─ index.less # All component styles entry(Uncompiled)
|
||||
├─ index.css # Bundle component styles for CDN
|
||||
├─ [name].js # Bundle script for UMD
|
||||
├─ [name].es.js # Bundle script for ESM
|
||||
├─ [name].min.js # Bundle and minified script for UMD
|
||||
└─ [name].es.min.js # Bundle and minified script for ESM
|
||||
```
|
||||
|
||||
单个组件编译后的目录如下:
|
||||
The compiled directory of a single component is as follows:
|
||||
|
||||
```
|
||||
button
|
||||
├─ index.js # 组件编译后的 JS 文件
|
||||
├─ index.css # 组件编译后的 CSS 文件
|
||||
├─ index.less # 组件编译前的 CSS 文件,可以为 less 或 scss
|
||||
└─ style # 按需引入样式的入口
|
||||
├─ index.js # 按需引入编译后的样式
|
||||
└─ less.js # 按需引入未编译的样式,可用于主题定制
|
||||
├─ index.js # Bundle script file
|
||||
├─ index.css # Bundle CSS file
|
||||
├─ index.less # Uncompiled CSS file, less or scss
|
||||
└─ style # Style entry on demand directory
|
||||
├─ index.js # Compiled styles on demand
|
||||
└─ less.js # Uncompiled styles on demand, for theme customization
|
||||
```
|
||||
|
||||
### 生成类型声明
|
||||
### Generate type definition
|
||||
|
||||
当组件库使用 TS 编写,且根目录下存在 `tsconfig.declaration.json` 文件,Vant Cli 会自动生成 `.d.ts` 类型声明文件。
|
||||
When the component library is written in TS and the `tsconfig.declaration.json` file exists in the root directory, Vant CLI will automatically generate the `.d.ts` type declaration file.
|
||||
|
||||
`tsconfig.declaration.json` 的参考格式如下:
|
||||
The format of `tsconfig.declaration.json` is as follows:
|
||||
|
||||
```json
|
||||
{
|
||||
@ -100,7 +100,7 @@ button
|
||||
}
|
||||
```
|
||||
|
||||
成功生成类型声明后,请在 `package.json` 中添加类型入口声明:
|
||||
Please add the `typings` field in `package.json` after generate type declaration:
|
||||
|
||||
```json
|
||||
{
|
||||
|
||||
109
packages/vant-cli/docs/directory.zh-CN.md
Normal file
109
packages/vant-cli/docs/directory.zh-CN.md
Normal file
@ -0,0 +1,109 @@
|
||||
# 目录结构
|
||||
|
||||
## 源代码目录
|
||||
|
||||
基于 Vant CLI 搭建的组件库的基本目录结构如下所示:
|
||||
|
||||
```
|
||||
project
|
||||
├─ src # 组件源代码
|
||||
│ ├─ button # button 组件源代码
|
||||
│ └─ dialog # dialog 组件源代码
|
||||
│
|
||||
├─ docs # 静态文档目录
|
||||
│ ├─ home.md # 文档首页
|
||||
│ └─ changelog.md # 更新日志
|
||||
│
|
||||
├─ vant.config.mjs # Vant CLI 配置文件
|
||||
├─ package.json
|
||||
└─ README.md
|
||||
```
|
||||
|
||||
单个组件的目录如下:
|
||||
|
||||
```
|
||||
button
|
||||
├─ demo # 示例目录
|
||||
│ └─ index.vue # 组件示例
|
||||
├─ index.vue # 组件源码
|
||||
└─ README.md # 组件文档
|
||||
```
|
||||
|
||||
使用 .vue 文件编写组件时,编译后会生成对应的 JS 和 CSS 文件,且 JS 文件中会自动引入 CSS 文件。
|
||||
|
||||
如果需要将 JS 和 CSS 解耦,实现主题定制等功能,在编写代码时就要使用独立的 JS 和 CSS 文件,如下所示:
|
||||
|
||||
```
|
||||
button
|
||||
├─ demo # 组件示例
|
||||
│ └─ index.vue # 组件示例入口
|
||||
├─ index.js # 组件入口
|
||||
├─ index.less # 组件样式,可以为 less 或 scss
|
||||
└─ README.md # 组件文档
|
||||
```
|
||||
|
||||
采用这种目录结构时,组件的使用者需要分别引入 JS 和 CSS 文件。
|
||||
|
||||
通过引入样式源文件(less 或 scss)并修改样式变量,可以实现主题定制功能。
|
||||
|
||||
## 构建结果目录
|
||||
|
||||
运行 build 命令会在 `es` 和 `lib` 目录下生成可用于生产环境的组件代码,结构如下:
|
||||
|
||||
```
|
||||
project
|
||||
├─ es # es 目录下的代码遵循 esmodule 规范
|
||||
│ ├─ button # button 组件编译后的代码目录
|
||||
│ ├─ dialog # dialog 组件编译后的代码目录
|
||||
│ └─ index.js # 引入所有组件的入口 (ESModule)
|
||||
│
|
||||
└─ lib # lib 目录下的代码遵循 commonjs 规范
|
||||
├─ button # button 组件编译后的代码目录
|
||||
├─ dialog # dialog 组件编译后的代码目录
|
||||
├─ index.js # 引入所有组件的入口
|
||||
├─ index.less # 所有组件未编译的样式入口
|
||||
├─ index.css # 打包后的组件样式,用于 CDN 引入
|
||||
├─ [name].js # 打包后的组件脚本,UMD 格式
|
||||
├─ [name].es.js # 打包后的组件脚本,ESModule 格式
|
||||
├─ [name].min.js # 打包和压缩后的组件脚本,UMD 格式
|
||||
└─ [name].es.min.js # 打包和压缩后的组件脚本,ESModule 格式
|
||||
```
|
||||
|
||||
单个组件编译后的目录如下:
|
||||
|
||||
```
|
||||
button
|
||||
├─ index.js # 组件编译后的 JS 文件
|
||||
├─ index.css # 组件编译后的 CSS 文件
|
||||
├─ index.less # 组件编译前的 CSS 文件,可以为 less 或 scss
|
||||
└─ style # 按需引入样式的入口
|
||||
├─ index.js # 按需引入编译后的样式
|
||||
└─ less.js # 按需引入未编译的样式,可用于主题定制
|
||||
```
|
||||
|
||||
### 生成类型声明
|
||||
|
||||
当组件库使用 TS 编写,且根目录下存在 `tsconfig.declaration.json` 文件,Vant CLI 会自动生成 `.d.ts` 类型声明文件。
|
||||
|
||||
`tsconfig.declaration.json` 的参考格式如下:
|
||||
|
||||
```json
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationDir": ".",
|
||||
"emitDeclarationOnly": true
|
||||
},
|
||||
"include": ["es/**/*", "lib/**/*"],
|
||||
"exclude": ["node_modules", "**/test/**/*", "**/demo/**/*"]
|
||||
}
|
||||
```
|
||||
|
||||
成功生成类型声明后,请在 `package.json` 中添加类型入口声明:
|
||||
|
||||
```json
|
||||
{
|
||||
"typings": "lib/index.d.ts"
|
||||
}
|
||||
```
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vant/cli",
|
||||
"version": "4.0.0",
|
||||
"version": "4.0.4",
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
"typings": "lib/index.d.ts",
|
||||
@ -32,64 +32,63 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/youzan/vant.git",
|
||||
"url": "https://github.com/vant-ui/vant.git",
|
||||
"directory": "packages/vant-cli"
|
||||
},
|
||||
"bugs": "https://github.com/youzan/vant/issues",
|
||||
"bugs": "https://github.com/vant-ui/vant/issues",
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@jest/types": "^27.5.1",
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/less": "^3.0.3",
|
||||
"@types/markdown-it": "^12.2.3",
|
||||
"vue": "^3.2.27"
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"vue": "^3.2.38"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.16.0",
|
||||
"@babel/preset-typescript": "^7.16.0",
|
||||
"@docsearch/css": "3.0.0-alpha.50",
|
||||
"@docsearch/js": "3.0.0-alpha.50",
|
||||
"@types/jest": "^27.0.3",
|
||||
"@vant/eslint-config": "^3.3.2",
|
||||
"@vant/markdown-vetur": "^2.2.0",
|
||||
"@vant/stylelint-config": "^1.4.2",
|
||||
"@vant/touch-emulator": "^1.3.2",
|
||||
"@vitejs/plugin-vue": "^2.0.0",
|
||||
"@vitejs/plugin-vue-jsx": "^1.3.3",
|
||||
"@babel/core": "^7.18.13",
|
||||
"@babel/preset-typescript": "^7.18.6",
|
||||
"@docsearch/css": "^3.2.1",
|
||||
"@docsearch/js": "^3.2.1",
|
||||
"@types/jest": "^27.5.2",
|
||||
"@vant/eslint-config": "^3.5.0",
|
||||
"@vant/touch-emulator": "^1.4.0",
|
||||
"@vitejs/plugin-vue": "^3.0.3",
|
||||
"@vitejs/plugin-vue-jsx": "^2.0.1",
|
||||
"@vue/babel-plugin-jsx": "^1.1.1",
|
||||
"autoprefixer": "^10.4.0",
|
||||
"chalk": "^4.1.2",
|
||||
"commander": "^8.3.0",
|
||||
"autoprefixer": "^10.4.8",
|
||||
"commander": "^9.4.0",
|
||||
"consola": "^2.15.3",
|
||||
"conventional-changelog": "^3.1.24",
|
||||
"esbuild": "^0.14.21",
|
||||
"eslint": "^8.1.0",
|
||||
"conventional-changelog": "^3.1.25",
|
||||
"esbuild": "^0.14.54",
|
||||
"eslint": "^8.23.0",
|
||||
"execa": "^5.1.1",
|
||||
"fast-glob": "^3.2.7",
|
||||
"fs-extra": "^10.0.0",
|
||||
"gh-pages": "^3.2.3",
|
||||
"fast-glob": "^3.2.11",
|
||||
"fs-extra": "^10.1.0",
|
||||
"hash-sum": "^2.0.0",
|
||||
"highlight.js": "^11.3.1",
|
||||
"husky": "^7.0.4",
|
||||
"jest": "^27.3.1",
|
||||
"jest-canvas-mock": "^2.3.1",
|
||||
"highlight.js": "^11.6.0",
|
||||
"husky": "^8.0.1",
|
||||
"jest": "^27.5.1",
|
||||
"jest-canvas-mock": "^2.4.0",
|
||||
"jest-serializer-html": "^7.1.0",
|
||||
"less": "^4.1.2",
|
||||
"lint-staged": "^12.1.2",
|
||||
"markdown-it": "^12.2.0",
|
||||
"markdown-it-anchor": "^8.4.1",
|
||||
"ora": "^6.0.1",
|
||||
"postcss": "^8.3.11",
|
||||
"postcss-load-config": "^3.1.0",
|
||||
"prettier": "^2.5.0",
|
||||
"release-it": "^14.11.6",
|
||||
"stylelint": "^13.0.0",
|
||||
"transliteration": "^2.2.0",
|
||||
"typescript": "^4.5.2",
|
||||
"vite": "^2.8.0",
|
||||
"vite-plugin-html": "^2.1.1",
|
||||
"vite-plugin-md": "^0.11.4",
|
||||
"vue-router": "^4.0.12"
|
||||
"less": "^4.1.3",
|
||||
"markdown-it": "^12.3.2",
|
||||
"markdown-it-anchor": "^8.6.4",
|
||||
"nano-staged": "^0.8.0",
|
||||
"nanospinner": "^1.1.0",
|
||||
"picocolors": "^1.0.0",
|
||||
"postcss": "^8.4.16",
|
||||
"postcss-load-config": "^3.1.4",
|
||||
"prettier": "^2.7.1",
|
||||
"release-it": "^15.4.1",
|
||||
"transliteration": "^2.3.5",
|
||||
"typescript": "^4.8.2",
|
||||
"vite": "^3.0.9",
|
||||
"vite-plugin-html": "^2.1.2",
|
||||
"vite-plugin-md": "^0.11.9",
|
||||
"vue-router": "^4.1.5"
|
||||
},
|
||||
"release-it": {
|
||||
"git": {
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
/**
|
||||
* 同步父窗口和 iframe 的 vue-router 状态
|
||||
*/
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { config } from 'site-desktop-shared';
|
||||
|
||||
let queue = [];
|
||||
@ -62,6 +59,49 @@ export function syncPathToChild() {
|
||||
}
|
||||
}
|
||||
|
||||
export function syncThemeToChild(theme) {
|
||||
const iframe = document.querySelector('iframe');
|
||||
if (iframe) {
|
||||
iframeReady(() => {
|
||||
iframe.contentWindow.postMessage(
|
||||
{
|
||||
type: 'updateTheme',
|
||||
value: theme,
|
||||
},
|
||||
'*'
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function getDefaultTheme() {
|
||||
const cache = window.localStorage.getItem('vantTheme');
|
||||
|
||||
if (cache) {
|
||||
return cache;
|
||||
}
|
||||
|
||||
const useDark =
|
||||
window.matchMedia &&
|
||||
window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
return useDark ? 'dark' : 'light';
|
||||
}
|
||||
|
||||
export function useCurrentTheme() {
|
||||
const theme = ref(getDefaultTheme());
|
||||
|
||||
window.addEventListener('message', (event) => {
|
||||
if (event.data?.type !== 'updateTheme') {
|
||||
return;
|
||||
}
|
||||
|
||||
const newTheme = event.data?.value || '';
|
||||
theme.value = newTheme;
|
||||
});
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
export function listenToSyncPath(router) {
|
||||
window.addEventListener('message', (event) => {
|
||||
if (event.data?.type !== 'replacePath') {
|
||||
@ -4,7 +4,7 @@ const isMobile = /ios|iphone|ipod|ipad|android/.test(ua);
|
||||
export function decamelize(str, sep = '-') {
|
||||
return str
|
||||
.replace(/([a-z\d])([A-Z])/g, '$1' + sep + '$2')
|
||||
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + sep + '$2')
|
||||
.replace(/([A-Z])([A-Z][a-z\d]+)/g, '$1' + sep + '$2')
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
@import './var';
|
||||
@import './font.less';
|
||||
@import './vars.less';
|
||||
|
||||
body {
|
||||
min-width: 1100px;
|
||||
margin: 0;
|
||||
overflow-x: auto;
|
||||
color: @van-doc-black;
|
||||
color: var(--van-doc-text-color-2);
|
||||
font-size: 16px;
|
||||
font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Helvetica Neue',
|
||||
Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui',
|
||||
'Hiragino Sans GB', 'Microsoft Yahei', sans-serif;
|
||||
background-color: @van-doc-background-color;
|
||||
background-color: var(--van-doc-background);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
@ -42,8 +41,8 @@ a {
|
||||
.van-doc-row {
|
||||
width: 100%;
|
||||
|
||||
@media (min-width: @van-doc-row-max-width) {
|
||||
width: @van-doc-row-max-width;
|
||||
@media (min-width: var(--van-doc-row-max-width)) {
|
||||
width: var(--van-doc-row-max-width);
|
||||
margin: 0 auto;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,163 +0,0 @@
|
||||
/* cyrillic-ext */
|
||||
@font-face {
|
||||
font-weight: 400;
|
||||
font-family: 'Open Sans';
|
||||
font-style: normal;
|
||||
src: local('Open Sans Regular'), local('OpenSans-Regular'),
|
||||
url(https://b.yzcdn.cn/vant/mem8YaGs126MiZpBA-UFWJ0bf8pkAp6a.woff2)
|
||||
format('woff2');
|
||||
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F,
|
||||
U+FE2E-FE2F;
|
||||
}
|
||||
|
||||
/* cyrillic */
|
||||
@font-face {
|
||||
font-weight: 400;
|
||||
font-family: 'Open Sans';
|
||||
font-style: normal;
|
||||
src: local('Open Sans Regular'), local('OpenSans-Regular'),
|
||||
url(https://b.yzcdn.cn/vant/mem8YaGs126MiZpBA-UFUZ0bf8pkAp6a.woff2)
|
||||
format('woff2');
|
||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
||||
}
|
||||
|
||||
/* greek-ext */
|
||||
@font-face {
|
||||
font-weight: 400;
|
||||
font-family: 'Open Sans';
|
||||
font-style: normal;
|
||||
src: local('Open Sans Regular'), local('OpenSans-Regular'),
|
||||
url(https://b.yzcdn.cn/vant/mem8YaGs126MiZpBA-UFWZ0bf8pkAp6a.woff2)
|
||||
format('woff2');
|
||||
unicode-range: U+1F00-1FFF;
|
||||
}
|
||||
|
||||
/* greek */
|
||||
@font-face {
|
||||
font-weight: 400;
|
||||
font-family: 'Open Sans';
|
||||
font-style: normal;
|
||||
src: local('Open Sans Regular'), local('OpenSans-Regular'),
|
||||
url(https://b.yzcdn.cn/vant/mem8YaGs126MiZpBA-UFVp0bf8pkAp6a.woff2)
|
||||
format('woff2');
|
||||
unicode-range: U+0370-03FF;
|
||||
}
|
||||
|
||||
/* vietnamese */
|
||||
@font-face {
|
||||
font-weight: 400;
|
||||
font-family: 'Open Sans';
|
||||
font-style: normal;
|
||||
src: local('Open Sans Regular'), local('OpenSans-Regular'),
|
||||
url(https://b.yzcdn.cn/vant/mem8YaGs126MiZpBA-UFWp0bf8pkAp6a.woff2)
|
||||
format('woff2');
|
||||
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1,
|
||||
U+01AF-01B0, U+1EA0-1EF9, U+20AB;
|
||||
}
|
||||
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-weight: 400;
|
||||
font-family: 'Open Sans';
|
||||
font-style: normal;
|
||||
src: local('Open Sans Regular'), local('OpenSans-Regular'),
|
||||
url(https://b.yzcdn.cn/vant/mem8YaGs126MiZpBA-UFW50bf8pkAp6a.woff2)
|
||||
format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB,
|
||||
U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-weight: 400;
|
||||
font-family: 'Open Sans';
|
||||
font-style: normal;
|
||||
src: local('Open Sans Regular'), local('OpenSans-Regular'),
|
||||
url(https://b.yzcdn.cn/vant/mem8YaGs126MiZpBA-UFVZ0bf8pkAg.woff2)
|
||||
format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
|
||||
U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
|
||||
U+FEFF, U+FFFD;
|
||||
}
|
||||
|
||||
/* cyrillic-ext */
|
||||
@font-face {
|
||||
font-weight: 600;
|
||||
font-family: 'Open Sans';
|
||||
font-style: normal;
|
||||
src: local('Open Sans SemiBold'), local('OpenSans-SemiBold'),
|
||||
url(https://b.yzcdn.cn/vant/mem5YaGs126MiZpBA-UNirkOX-hpKKSTj5PW.woff2)
|
||||
format('woff2');
|
||||
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F,
|
||||
U+FE2E-FE2F;
|
||||
}
|
||||
|
||||
/* cyrillic */
|
||||
@font-face {
|
||||
font-weight: 600;
|
||||
font-family: 'Open Sans';
|
||||
font-style: normal;
|
||||
src: local('Open Sans SemiBold'), local('OpenSans-SemiBold'),
|
||||
url(https://b.yzcdn.cn/vant/mem5YaGs126MiZpBA-UNirkOVuhpKKSTj5PW.woff2)
|
||||
format('woff2');
|
||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
||||
}
|
||||
|
||||
/* greek-ext */
|
||||
@font-face {
|
||||
font-weight: 600;
|
||||
font-family: 'Open Sans';
|
||||
font-style: normal;
|
||||
src: local('Open Sans SemiBold'), local('OpenSans-SemiBold'),
|
||||
url(https://b.yzcdn.cn/vant/mem5YaGs126MiZpBA-UNirkOXuhpKKSTj5PW.woff2)
|
||||
format('woff2');
|
||||
unicode-range: U+1F00-1FFF;
|
||||
}
|
||||
|
||||
/* greek */
|
||||
@font-face {
|
||||
font-weight: 600;
|
||||
font-family: 'Open Sans';
|
||||
font-style: normal;
|
||||
src: local('Open Sans SemiBold'), local('OpenSans-SemiBold'),
|
||||
url(https://b.yzcdn.cn/vant/mem5YaGs126MiZpBA-UNirkOUehpKKSTj5PW.woff2)
|
||||
format('woff2');
|
||||
unicode-range: U+0370-03FF;
|
||||
}
|
||||
|
||||
/* vietnamese */
|
||||
@font-face {
|
||||
font-weight: 600;
|
||||
font-family: 'Open Sans';
|
||||
font-style: normal;
|
||||
src: local('Open Sans SemiBold'), local('OpenSans-SemiBold'),
|
||||
url(https://b.yzcdn.cn/vant/mem5YaGs126MiZpBA-UNirkOXehpKKSTj5PW.woff2)
|
||||
format('woff2');
|
||||
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1,
|
||||
U+01AF-01B0, U+1EA0-1EF9, U+20AB;
|
||||
}
|
||||
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-weight: 600;
|
||||
font-family: 'Open Sans';
|
||||
font-style: normal;
|
||||
src: local('Open Sans SemiBold'), local('OpenSans-SemiBold'),
|
||||
url(https://b.yzcdn.cn/vant/mem5YaGs126MiZpBA-UNirkOXOhpKKSTj5PW.woff2)
|
||||
format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB,
|
||||
U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-weight: 600;
|
||||
font-family: 'Open Sans';
|
||||
font-style: normal;
|
||||
src: local('Open Sans SemiBold'), local('OpenSans-SemiBold'),
|
||||
url(https://b.yzcdn.cn/vant/mem5YaGs126MiZpBA-UNirkOUuhpKKSTjw.woff2)
|
||||
format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
|
||||
U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
|
||||
U+FEFF, U+FFFD;
|
||||
}
|
||||
@ -1,20 +1,18 @@
|
||||
@import './var';
|
||||
|
||||
code {
|
||||
position: relative;
|
||||
display: block;
|
||||
padding: 16px 20px;
|
||||
overflow-x: auto;
|
||||
color: @van-doc-code-color;
|
||||
color: var(--van-doc-code-color);
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
font-family: @van-doc-code-font-family;
|
||||
font-family: 'Source Code Pro', 'Monaco', 'Inconsolata', monospace;
|
||||
line-height: 26px;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
-webkit-font-smoothing: auto;
|
||||
background-color: #f8f8f8;
|
||||
border-radius: @van-doc-border-radius;
|
||||
background-color: var(--van-doc-code-background);
|
||||
border-radius: var(--van-doc-border-radius);
|
||||
}
|
||||
|
||||
pre {
|
||||
@ -33,7 +31,7 @@ pre {
|
||||
}
|
||||
|
||||
.hljs-subst {
|
||||
color: @van-doc-code-color;
|
||||
color: var(--van-doc-code-color);
|
||||
}
|
||||
|
||||
.hljs-string,
|
||||
@ -42,18 +40,18 @@ pre {
|
||||
.hljs-template-tag,
|
||||
.hljs-template-variable,
|
||||
.hljs-addition {
|
||||
color: @van-doc-green;
|
||||
color: var(--van-doc-green);
|
||||
}
|
||||
|
||||
.hljs-comment,
|
||||
.hljs-quote {
|
||||
color: #999;
|
||||
color: var(--van-doc-code-comment-color);
|
||||
}
|
||||
|
||||
.hljs-params,
|
||||
.hljs-keyword,
|
||||
.hljs-attribute {
|
||||
color: @van-doc-purple;
|
||||
color: var(--van-doc-purple);
|
||||
}
|
||||
|
||||
.hljs-deletion,
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
@van-doc-black: #323233;
|
||||
@van-doc-blue: #1989fa;
|
||||
@van-doc-purple: #8080ff;
|
||||
@van-doc-fuchsia: #a7419e;
|
||||
@van-doc-green: #4fc08d;
|
||||
@van-doc-text-color: #34495e;
|
||||
@van-doc-text-light-blue: rgba(69, 90, 100, 0.6);
|
||||
@van-doc-background-color: #f7f8fa;
|
||||
@van-doc-grey: #999;
|
||||
@van-doc-dark-grey: #666;
|
||||
@van-doc-light-grey: #ccc;
|
||||
@van-doc-border-color: #f1f4f8;
|
||||
@van-doc-code-color: #58727e;
|
||||
@van-doc-code-background-color: #f1f4f8;
|
||||
@van-doc-code-font-family: 'Source Code Pro', 'Monaco', 'Inconsolata', monospace;
|
||||
@van-doc-padding: 24px;
|
||||
@van-doc-row-max-width: 1680px;
|
||||
@van-doc-nav-width: 220px;
|
||||
@van-doc-border-radius: 20px;
|
||||
|
||||
// header
|
||||
@van-doc-header-top-height: 64px;
|
||||
@van-doc-header-bottom-height: 50px;
|
||||
|
||||
// simulator
|
||||
@van-doc-simulator-width: 360px;
|
||||
@van-doc-simulator-height: 620px;
|
||||
74
packages/vant-cli/site/common/style/vars.less
Normal file
74
packages/vant-cli/site/common/style/vars.less
Normal file
@ -0,0 +1,74 @@
|
||||
body {
|
||||
// colors
|
||||
--van-doc-black: #000;
|
||||
--van-doc-white: #fff;
|
||||
--van-doc-gray-1: #f7f8fa;
|
||||
--van-doc-gray-2: #f2f3f5;
|
||||
--van-doc-gray-3: #ebedf0;
|
||||
--van-doc-gray-4: #dcdee0;
|
||||
--van-doc-gray-5: #c8c9cc;
|
||||
--van-doc-gray-6: #969799;
|
||||
--van-doc-gray-7: #646566;
|
||||
--van-doc-gray-8: #323233;
|
||||
--van-doc-blue: #1989fa;
|
||||
--van-doc-green: #07c160;
|
||||
|
||||
// sizes
|
||||
--van-doc-padding: 24px;
|
||||
--van-doc-row-max-width: 1680px;
|
||||
--van-doc-nav-width: 220px;
|
||||
--van-doc-border-radius: 20px;
|
||||
--van-doc-simulator-width: 360px;
|
||||
--van-doc-simulator-height: 620px;
|
||||
--van-doc-header-top-height: 64px;
|
||||
}
|
||||
|
||||
.van-doc-theme-light {
|
||||
// text
|
||||
--van-doc-text-color-1: var(--van-doc-black);
|
||||
--van-doc-text-color-2: var(--van-doc-gray-8);
|
||||
--van-doc-text-color-3: #34495e;
|
||||
--van-doc-text-color-4: var(--van-doc-gray-6);
|
||||
--van-doc-link-color: var(--van-doc-blue);
|
||||
|
||||
// background
|
||||
--van-doc-background: #eff2f5;
|
||||
--van-doc-background-2: var(--van-doc-white);
|
||||
--van-doc-background-3: var(--van-doc-white);
|
||||
--van-doc-header-background: #011f3c;
|
||||
--van-doc-border-color: var(--van-doc-gray-2);
|
||||
|
||||
// code
|
||||
--van-doc-code-color: #58727e;
|
||||
--van-doc-code-comment-color: var(--van-doc-gray-6);
|
||||
--van-doc-code-background: var(--van-doc-gray-1);
|
||||
|
||||
// blockquote
|
||||
--van-doc-blockquote-color: #4994df;
|
||||
--van-doc-blockquote-background: #ecf9ff;
|
||||
}
|
||||
|
||||
.van-doc-theme-dark {
|
||||
// text
|
||||
--van-doc-text-color-1: var(--van-doc-white);
|
||||
--van-doc-text-color-2: rgba(255, 255, 255, 0.9);
|
||||
--van-doc-text-color-3: rgba(255, 255, 255, 0.75);
|
||||
--van-doc-text-color-4: rgba(255, 255, 255, 0.6);
|
||||
--van-doc-link-color: #1bb5fe;
|
||||
|
||||
// background
|
||||
--van-doc-background: #202124;
|
||||
--van-doc-background-2: rgba(255, 255, 255, 0.06);
|
||||
--van-doc-background-3: rgba(255, 255, 255, 0.1);
|
||||
--van-doc-header-background: rgba(1, 31, 60, 0.3);
|
||||
--van-doc-border-color: #3a3a3c;
|
||||
|
||||
// code
|
||||
--van-doc-code-color: rgba(200, 200, 200, 0.85);
|
||||
--van-doc-code-comment-color: var(--van-doc-gray-7);
|
||||
--van-doc-code-background: rgba(0, 0, 0, 0.24);
|
||||
|
||||
// blockquote
|
||||
--van-doc-blockquote-color: #bae6fd;
|
||||
--van-doc-blockquote-background: rgba(7, 89, 133, 0.25);
|
||||
}
|
||||
@ -8,6 +8,7 @@
|
||||
:simulator="simulator"
|
||||
:has-simulator="hasSimulator"
|
||||
:lang-configs="langConfigs"
|
||||
:dark-mode-class="darkModeClass"
|
||||
>
|
||||
<router-view />
|
||||
</van-doc>
|
||||
@ -27,6 +28,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
hasSimulator: true,
|
||||
darkModeClass: config.site.darkModeClass,
|
||||
};
|
||||
},
|
||||
|
||||
@ -70,18 +72,18 @@ export default {
|
||||
watch: {
|
||||
// eslint-disable-next-line
|
||||
'$route.path'() {
|
||||
this.setTitleAndToogleSimulator();
|
||||
this.setTitleAndToggleSimulator();
|
||||
},
|
||||
|
||||
lang(val) {
|
||||
setLang(val);
|
||||
this.setTitleAndToogleSimulator();
|
||||
this.setTitleAndToggleSimulator();
|
||||
},
|
||||
|
||||
config: {
|
||||
handler(val) {
|
||||
if (val) {
|
||||
this.setTitleAndToogleSimulator();
|
||||
this.setTitleAndToggleSimulator();
|
||||
}
|
||||
},
|
||||
immediate: true,
|
||||
@ -100,7 +102,7 @@ export default {
|
||||
},
|
||||
|
||||
methods: {
|
||||
setTitleAndToogleSimulator() {
|
||||
setTitleAndToggleSimulator() {
|
||||
let { title } = this.config;
|
||||
|
||||
const navItems = this.config.nav.reduce(
|
||||
|
||||
@ -18,18 +18,18 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@import '../../common/style/var';
|
||||
|
||||
.van-doc-container {
|
||||
box-sizing: border-box;
|
||||
padding-left: @van-doc-nav-width;
|
||||
padding-left: var(--van-doc-nav-width);
|
||||
overflow: hidden;
|
||||
|
||||
&--with-simulator {
|
||||
padding-right: @van-doc-simulator-width + @van-doc-padding;
|
||||
padding-right: calc(
|
||||
var(--van-doc-simulator-width) + var(--van-doc-padding)
|
||||
);
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
padding-right: @van-doc-simulator-width - 8px;
|
||||
padding-right: calc(var(--van-doc-simulator-width) - 8px);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,14 +82,12 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@import '../../common/style/var';
|
||||
|
||||
.van-doc-card {
|
||||
margin-bottom: 24px;
|
||||
padding: 24px;
|
||||
background-color: #fff;
|
||||
border-radius: @van-doc-border-radius;
|
||||
box-shadow: 0 8px 12px #ebedf0;
|
||||
background-color: var(--van-doc-background-2);
|
||||
border-radius: var(--van-doc-border-radius);
|
||||
overflow: auto;
|
||||
|
||||
> pre code {
|
||||
position: relative;
|
||||
@ -144,15 +142,15 @@ export default {
|
||||
> table a,
|
||||
> blockquote a {
|
||||
margin: 0 1px;
|
||||
color: @van-doc-blue;
|
||||
color: var(--van-doc-link-color);
|
||||
-webkit-font-smoothing: auto;
|
||||
|
||||
&:hover {
|
||||
color: darken(@van-doc-blue, 10%);
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
&:active {
|
||||
color: darken(@van-doc-blue, 20%);
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,7 +158,6 @@ export default {
|
||||
> h4,
|
||||
> h5,
|
||||
> h6 {
|
||||
color: @van-doc-black;
|
||||
font-weight: normal;
|
||||
line-height: 1.6;
|
||||
|
||||
@ -189,23 +186,19 @@ export default {
|
||||
|
||||
> p {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
> p,
|
||||
> blockquote p {
|
||||
color: @van-doc-text-color;
|
||||
color: var(--van-doc-text-color-3);
|
||||
font-size: 15px;
|
||||
line-height: 26px;
|
||||
|
||||
strong {
|
||||
color: black;
|
||||
color: var(--van-doc-text-color-1);
|
||||
}
|
||||
}
|
||||
|
||||
> table {
|
||||
width: 100%;
|
||||
margin-top: 12px;
|
||||
color: @van-doc-text-color;
|
||||
color: var(--van-doc-text-color-3);
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
border-collapse: collapse;
|
||||
@ -226,7 +219,7 @@ export default {
|
||||
|
||||
td {
|
||||
padding: 8px;
|
||||
border-top: 1px solid @van-doc-code-background-color;
|
||||
border-top: 1px solid var(--van-doc-border-color);
|
||||
|
||||
&:first-child {
|
||||
padding-left: 0;
|
||||
@ -235,10 +228,10 @@ export default {
|
||||
code {
|
||||
margin: 0;
|
||||
padding: 2px 6px;
|
||||
color: @van-doc-blue;
|
||||
color: var(--van-doc-blue);
|
||||
font-weight: 600;
|
||||
font-size: 11px;
|
||||
background-color: fade(@van-doc-blue, 10%);
|
||||
background-color: rgba(25, 137, 250, 0.15);
|
||||
border-radius: 20px;
|
||||
}
|
||||
}
|
||||
@ -250,9 +243,9 @@ export default {
|
||||
|
||||
em {
|
||||
display: inline-block;
|
||||
color: @van-doc-green;
|
||||
color: var(--van-doc-green);
|
||||
font-size: 14px;
|
||||
font-family: @van-doc-code-font-family;
|
||||
font-family: 'Source Code Pro', 'Monaco', 'Inconsolata', monospace;
|
||||
font-style: normal;
|
||||
max-width: 300px;
|
||||
-webkit-font-smoothing: auto;
|
||||
@ -268,7 +261,7 @@ export default {
|
||||
position: relative;
|
||||
margin: 5px 0 5px 10px;
|
||||
padding-left: 15px;
|
||||
color: @van-doc-text-color;
|
||||
color: var(--van-doc-text-color-3);
|
||||
font-size: 15px;
|
||||
line-height: 26px;
|
||||
|
||||
@ -280,7 +273,7 @@ export default {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
margin-top: 10px;
|
||||
border: 1px solid @van-doc-dark-grey;
|
||||
border: 1px solid currentColor;
|
||||
border-radius: 50%;
|
||||
content: '';
|
||||
}
|
||||
@ -310,15 +303,17 @@ export default {
|
||||
> blockquote {
|
||||
margin: 16px 0 0;
|
||||
padding: 16px;
|
||||
background-color: #ecf9ff;
|
||||
border-radius: @van-doc-border-radius;
|
||||
font-size: 14px;
|
||||
color: var(--van-doc-blockquote-color);
|
||||
background-color: var(--van-doc-blockquote-background);
|
||||
border-radius: var(--van-doc-border-radius);
|
||||
}
|
||||
|
||||
> img,
|
||||
> p img {
|
||||
width: 100%;
|
||||
margin: 16px 0;
|
||||
border-radius: @van-doc-border-radius;
|
||||
border-radius: var(--van-doc-border-radius);
|
||||
}
|
||||
}
|
||||
|
||||
@ -333,7 +328,6 @@ export default {
|
||||
|
||||
h1,
|
||||
h2 {
|
||||
color: @van-doc-black;
|
||||
font-weight: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
|
||||
@ -24,6 +24,16 @@
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li v-if="darkModeClass" class="van-doc-header__top-nav-item">
|
||||
<a
|
||||
class="van-doc-header__link"
|
||||
target="_blank"
|
||||
@click="toggleTheme"
|
||||
>
|
||||
<img :src="themeImg" />
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li
|
||||
ref="version"
|
||||
v-if="versions"
|
||||
@ -69,6 +79,7 @@
|
||||
<script>
|
||||
import SearchInput from './SearchInput.vue';
|
||||
import { packageVersion } from 'site-desktop-shared';
|
||||
import { getDefaultTheme, syncThemeToChild } from '../../common/iframe-sync';
|
||||
|
||||
export default {
|
||||
name: 'VanDocHeader',
|
||||
@ -82,10 +93,12 @@ export default {
|
||||
config: Object,
|
||||
versions: Array,
|
||||
langConfigs: Array,
|
||||
darkModeClass: String,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
currentTheme: getDefaultTheme(),
|
||||
packageVersion,
|
||||
showVersionPop: false,
|
||||
};
|
||||
@ -112,9 +125,32 @@ export default {
|
||||
searchConfig() {
|
||||
return this.config.searchConfig;
|
||||
},
|
||||
|
||||
themeImg() {
|
||||
if (this.currentTheme === 'light') {
|
||||
return 'https://b.yzcdn.cn/vant/dark-theme.svg';
|
||||
}
|
||||
return 'https://b.yzcdn.cn/vant/light-theme.svg';
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
currentTheme: {
|
||||
handler(newVal, oldVal) {
|
||||
window.localStorage.setItem('vantTheme', newVal);
|
||||
document.body.classList.remove(`van-doc-theme-${oldVal}`);
|
||||
document.body.classList.add(`van-doc-theme-${newVal}`);
|
||||
syncThemeToChild(newVal);
|
||||
},
|
||||
immediate: true,
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
toggleTheme() {
|
||||
this.currentTheme = this.currentTheme === 'light' ? 'dark' : 'light';
|
||||
},
|
||||
|
||||
toggleVersionPop() {
|
||||
const val = !this.showVersionPop;
|
||||
|
||||
@ -147,18 +183,16 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@import '../../common/style/var';
|
||||
|
||||
.van-doc-header {
|
||||
width: 100%;
|
||||
background-color: #001938;
|
||||
background-color: var(--van-doc-header-background);
|
||||
user-select: none;
|
||||
|
||||
&__top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: @van-doc-header-top-height;
|
||||
padding: 0 @van-doc-padding;
|
||||
height: var(--van-doc-header-top-height);
|
||||
padding: 0 var(--van-doc-padding);
|
||||
|
||||
&-nav {
|
||||
flex: 1;
|
||||
@ -234,7 +268,7 @@ export default {
|
||||
transition: 0.2s;
|
||||
|
||||
&:hover {
|
||||
color: @van-doc-blue;
|
||||
color: var(--van-doc-link-color);
|
||||
background-color: #f7f8fa;
|
||||
}
|
||||
}
|
||||
@ -268,6 +302,8 @@ export default {
|
||||
}
|
||||
|
||||
&__link {
|
||||
cursor: pointer;
|
||||
|
||||
span {
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
|
||||
@ -71,22 +71,19 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@import '../../common/style/var';
|
||||
|
||||
.van-doc-nav {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
z-index: 1;
|
||||
min-width: @van-doc-nav-width;
|
||||
max-width: @van-doc-nav-width;
|
||||
padding: @van-doc-padding 0;
|
||||
min-width: var(--van-doc-nav-width);
|
||||
max-width: var(--van-doc-nav-width);
|
||||
padding: 8px 0;
|
||||
overflow-y: scroll;
|
||||
background-color: #fff;
|
||||
box-shadow: 0 8px 12px #ebedf0;
|
||||
background-color: var(--van-doc-background-2);
|
||||
|
||||
@media (min-width: @van-doc-row-max-width) {
|
||||
@media (min-width: var(--van-doc-row-max-width)) {
|
||||
left: 50%;
|
||||
margin-left: -(@van-doc-row-max-width / 2);
|
||||
margin-left: calc((var(--van-doc-row-max-width) / 2 * -1));
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
@ -110,8 +107,8 @@ export default {
|
||||
}
|
||||
|
||||
&__title {
|
||||
padding: 8px 0 8px @van-doc-padding;
|
||||
color: #455a64;
|
||||
padding: 24px 0 0 var(--van-doc-padding);
|
||||
color: var(--van-doc-text-color-2);
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
line-height: 28px;
|
||||
@ -121,21 +118,19 @@ export default {
|
||||
a {
|
||||
display: block;
|
||||
margin: 8px 0;
|
||||
padding: 8px 0 8px @van-doc-padding;
|
||||
color: #455a64;
|
||||
padding: 6px 0 6px var(--van-doc-padding);
|
||||
color: var(--van-doc-text-color-3);
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
transition: color 0.2s;
|
||||
|
||||
&:hover,
|
||||
&.active {
|
||||
color: @van-doc-green;
|
||||
color: var(--van-doc-link-color);
|
||||
}
|
||||
|
||||
&.active {
|
||||
font-weight: 600;
|
||||
background-color: #ebfff0;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
span {
|
||||
|
||||
@ -3,9 +3,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import '@docsearch/css';
|
||||
import docsearch from '@docsearch/js';
|
||||
|
||||
export default {
|
||||
name: 'VanDocSearch',
|
||||
|
||||
@ -27,9 +24,12 @@ export default {
|
||||
methods: {
|
||||
initDocsearch() {
|
||||
if (this.searchConfig) {
|
||||
docsearch({
|
||||
...this.searchConfig,
|
||||
container: '#docsearch',
|
||||
import('@docsearch/css');
|
||||
import('@docsearch/js').then((docsearch) => {
|
||||
docsearch.default({
|
||||
...this.searchConfig,
|
||||
container: '#docsearch',
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -38,8 +38,6 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@import '../../common/style/var';
|
||||
|
||||
#docsearch {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
|
||||
@ -44,34 +44,31 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@import '../../common/style/var';
|
||||
|
||||
.van-doc-simulator {
|
||||
position: absolute;
|
||||
top: @van-doc-padding + @van-doc-header-top-height;
|
||||
right: @van-doc-padding;
|
||||
top: calc(var(--van-doc-padding) + var(--van-doc-header-top-height));
|
||||
right: var(--van-doc-padding);
|
||||
z-index: 1;
|
||||
box-sizing: border-box;
|
||||
width: @van-doc-simulator-width;
|
||||
min-width: @van-doc-simulator-width;
|
||||
width: var(--van-doc-simulator-width);
|
||||
min-width: var(--van-doc-simulator-width);
|
||||
overflow: hidden;
|
||||
background: #fafafa;
|
||||
border-radius: @van-doc-border-radius;
|
||||
box-shadow: 0 8px 12px #ebedf0;
|
||||
background: var(--van-doc-background-2);
|
||||
border-radius: var(--van-doc-border-radius);
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
right: auto;
|
||||
left: 750px;
|
||||
}
|
||||
|
||||
@media (min-width: @van-doc-row-max-width) {
|
||||
@media (min-width: var(--van-doc-row-max-width)) {
|
||||
right: 50%;
|
||||
margin-right: -(@van-doc-row-max-width / 2) + 24px;
|
||||
margin-right: calc(var(--van-doc-row-max-width) / 2 * -1 + 24px);
|
||||
}
|
||||
|
||||
&-fixed {
|
||||
position: fixed;
|
||||
top: @van-doc-padding;
|
||||
top: var(--van-doc-padding);
|
||||
}
|
||||
|
||||
iframe {
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
:config="config"
|
||||
:versions="versions"
|
||||
:lang-configs="langConfigs"
|
||||
:dark-mode-class="darkModeClass"
|
||||
@switch-version="$emit('switch-version', $event)"
|
||||
/>
|
||||
<doc-nav :lang="lang" :nav-config="config.nav" />
|
||||
@ -39,8 +40,9 @@ export default {
|
||||
lang: String,
|
||||
versions: Array,
|
||||
simulator: String,
|
||||
hasSimulator: Boolean,
|
||||
langConfigs: Array,
|
||||
hasSimulator: Boolean,
|
||||
darkModeClass: String,
|
||||
config: {
|
||||
type: Object,
|
||||
required: true,
|
||||
@ -108,7 +110,3 @@ export default {
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@import '../../common/style/var';
|
||||
</style>
|
||||
|
||||
@ -3,7 +3,7 @@ import { createRouter, createWebHashHistory } from 'vue-router';
|
||||
import { isMobile, decamelize } from '../common';
|
||||
import { config, documents } from 'site-desktop-shared';
|
||||
import { getLang, setDefaultLang } from '../common/locales';
|
||||
import { listenToSyncPath, syncPathToChild } from '../common/iframe-router';
|
||||
import { listenToSyncPath, syncPathToChild } from '../common/iframe-sync';
|
||||
|
||||
if (isMobile) {
|
||||
location.replace('mobile.html' + location.hash);
|
||||
|
||||
@ -15,6 +15,9 @@
|
||||
<meta http-equiv="Cache-Control" content="no-cache" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<% if (headHtml) { %>
|
||||
<%- headHtml %>
|
||||
<% } %>
|
||||
<% if (baiduAnalytics) { %>
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
@ -27,7 +30,7 @@
|
||||
</script>
|
||||
<% } %>
|
||||
</head>
|
||||
<body ontouchstart>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/desktop/main.js"></script>
|
||||
</body>
|
||||
|
||||
@ -15,6 +15,9 @@
|
||||
<meta http-equiv="Cache-Control" content="no-cache" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<% if (headHtml) { %>
|
||||
<%- headHtml %>
|
||||
<% } %>
|
||||
<% if (enableVConsole) { %>
|
||||
<script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
|
||||
<script>
|
||||
@ -36,7 +39,7 @@
|
||||
</script>
|
||||
<% } %>
|
||||
</head>
|
||||
<body ontouchstart>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/mobile/main.js"></script>
|
||||
</body>
|
||||
|
||||
@ -10,21 +10,49 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { watch } from 'vue';
|
||||
import DemoNav from './components/DemoNav.vue';
|
||||
import { useCurrentTheme } from '../common/iframe-sync';
|
||||
import { config } from 'site-mobile-shared';
|
||||
|
||||
export default {
|
||||
components: { DemoNav },
|
||||
|
||||
setup() {
|
||||
const theme = useCurrentTheme();
|
||||
|
||||
watch(
|
||||
theme,
|
||||
(newVal, oldVal) => {
|
||||
document.body.classList.remove(`van-doc-theme-${oldVal}`);
|
||||
document.body.classList.add(`van-doc-theme-${newVal}`);
|
||||
|
||||
const { darkModeClass } = config.site;
|
||||
if (darkModeClass) {
|
||||
document.body.classList.toggle(darkModeClass, newVal === 'dark');
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@import '../common/style/var';
|
||||
@import '../common/style/base';
|
||||
|
||||
body {
|
||||
min-width: 100vw;
|
||||
}
|
||||
|
||||
.van-doc-theme-light {
|
||||
background-color: var(--van-doc-gray-1);
|
||||
}
|
||||
|
||||
.van-doc-theme-dark {
|
||||
background-color: var(--van-doc-black);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 0;
|
||||
background: transparent;
|
||||
|
||||
@ -20,13 +20,11 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@import '../../common/style/var';
|
||||
|
||||
.van-doc-demo-block {
|
||||
&__title {
|
||||
margin: 0;
|
||||
padding: 32px 16px 16px;
|
||||
color: @van-doc-text-light-blue;
|
||||
color: var(--van-doc-text-color-4);
|
||||
font-weight: normal;
|
||||
font-size: 14px;
|
||||
line-height: 16px;
|
||||
|
||||
@ -52,14 +52,11 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@import '../../common/style/var';
|
||||
|
||||
.demo-home {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
padding: 46px 20px 20px;
|
||||
background: #fff;
|
||||
|
||||
&__title,
|
||||
&__desc {
|
||||
@ -94,7 +91,7 @@ export default {
|
||||
|
||||
&__desc {
|
||||
margin: 0 0 40px;
|
||||
color: rgba(69, 90, 100, 0.6);
|
||||
color: var(--van-doc-text-color-4);
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,12 +43,10 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@import '../../common/style/var';
|
||||
|
||||
.demo-home-nav {
|
||||
&__title {
|
||||
margin: 24px 0 8px 16px;
|
||||
color: rgba(69, 90, 100, 0.6);
|
||||
color: var(--van-doc-text-color-4);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
@ -57,20 +55,20 @@ export default {
|
||||
display: flex;
|
||||
margin: 0 0 12px;
|
||||
padding-left: 20px;
|
||||
color: #323233;
|
||||
color: var(--van-doc-text-color-3);
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
line-height: 40px;
|
||||
background: #f7f8fa;
|
||||
background-color: var(--van-doc-background-3);
|
||||
border-radius: 99px;
|
||||
transition: background 0.3s;
|
||||
transition: opacity 0.3s;
|
||||
|
||||
&:hover {
|
||||
background: darken(#f7f8fa, 3%);
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: darken(#f7f8fa, 6%);
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ export default {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 56px;
|
||||
background-color: #fff;
|
||||
background-color: var(--van-doc-background-3);
|
||||
|
||||
&__title {
|
||||
font-weight: 600;
|
||||
|
||||
@ -13,3 +13,8 @@ window.app = createApp(App)
|
||||
setTimeout(() => {
|
||||
window.app.mount('#app');
|
||||
}, 0);
|
||||
|
||||
// https://stackoverflow.com/questions/3885018/active-pseudo-class-doesnt-work-in-mobile-safari/33681490#33681490
|
||||
document.addEventListener('touchstart', () => {}, {
|
||||
passive: true,
|
||||
});
|
||||
|
||||
@ -4,7 +4,7 @@ import DemoHome from './components/DemoHome.vue';
|
||||
import { decamelize } from '../common';
|
||||
import { demos, config } from 'site-mobile-shared';
|
||||
import { getLang, setDefaultLang } from '../common/locales';
|
||||
import { listenToSyncPath, syncPathToParent } from '../common/iframe-router';
|
||||
import { listenToSyncPath, syncPathToParent } from '../common/iframe-sync';
|
||||
|
||||
const { locales, defaultLang } = config.site;
|
||||
|
||||
|
||||
@ -1,25 +1,26 @@
|
||||
import { Command } from 'commander';
|
||||
|
||||
import {
|
||||
dev,
|
||||
lint,
|
||||
test,
|
||||
clean,
|
||||
build,
|
||||
release,
|
||||
changelog,
|
||||
buildSite,
|
||||
commitLint,
|
||||
cliVersion,
|
||||
} from './index.js';
|
||||
import { cliVersion } from './index.js';
|
||||
|
||||
const program = new Command();
|
||||
|
||||
program.version(`@vant/cli ${cliVersion}`);
|
||||
|
||||
program.command('dev').description('Run dev server').action(dev);
|
||||
program
|
||||
.command('dev')
|
||||
.description('Run dev server')
|
||||
.action(async () => {
|
||||
const { dev } = await import('./commands/dev.js');
|
||||
return dev();
|
||||
});
|
||||
|
||||
program.command('lint').description('Run eslint and stylelint').action(lint);
|
||||
program
|
||||
.command('lint')
|
||||
.description('Run ESLint')
|
||||
.action(async () => {
|
||||
const { lint } = await import('./commands/lint.js');
|
||||
return lint();
|
||||
});
|
||||
|
||||
program
|
||||
.command('test')
|
||||
@ -45,34 +46,58 @@ program
|
||||
'Run all tests serially in the current process, rather than creating a worker pool of child processes that run tests'
|
||||
)
|
||||
.option('--debug', 'Print debugging info about your Jest config')
|
||||
.action(test);
|
||||
.action(async (options) => {
|
||||
const { test } = await import('./commands/jest.js');
|
||||
return test(options);
|
||||
});
|
||||
|
||||
program.command('clean').description('Clean all dist files').action(clean);
|
||||
program
|
||||
.command('clean')
|
||||
.description('Clean all dist files')
|
||||
.action(async () => {
|
||||
const { clean } = await import('./commands/clean.js');
|
||||
return clean();
|
||||
});
|
||||
|
||||
program
|
||||
.command('build')
|
||||
.description('Compile components in production mode')
|
||||
.action(build);
|
||||
.action(async () => {
|
||||
const { build } = await import('./commands/build.js');
|
||||
return build();
|
||||
});
|
||||
|
||||
program
|
||||
.command('release')
|
||||
.description('Compile components and release it')
|
||||
.option('--tag <tag>', 'Release tag')
|
||||
.action(release);
|
||||
.action(async (options) => {
|
||||
const { release } = await import('./commands/release.js');
|
||||
return release(options);
|
||||
});
|
||||
|
||||
program
|
||||
.command('build-site')
|
||||
.description('Compile site in production mode')
|
||||
.action(buildSite);
|
||||
.action(async () => {
|
||||
const { buildSite } = await import('./commands/build-site.js');
|
||||
return buildSite();
|
||||
});
|
||||
|
||||
program
|
||||
.command('changelog')
|
||||
.description('Generate changelog')
|
||||
.action(changelog);
|
||||
.action(async () => {
|
||||
const { changelog } = await import('./commands/changelog.js');
|
||||
return changelog();
|
||||
});
|
||||
|
||||
program
|
||||
.command('commit-lint <gitParams>')
|
||||
.description('Lint commit message')
|
||||
.action(commitLint);
|
||||
.action(async (gitParams) => {
|
||||
const { commitLint } = await import('./commands/commit-lint.js');
|
||||
return commitLint(gitParams);
|
||||
});
|
||||
|
||||
program.parse();
|
||||
|
||||
@ -3,7 +3,7 @@ import execa from 'execa';
|
||||
import { join, relative } from 'path';
|
||||
import { clean } from './clean.js';
|
||||
import { CSS_LANG } from '../common/css.js';
|
||||
import { ora, consola } from '../common/logger.js';
|
||||
import { createSpinner, consola } from '../common/logger.js';
|
||||
import { installDependencies } from '../common/manager.js';
|
||||
import { compileSfc } from '../compiler/compile-sfc.js';
|
||||
import { compileStyle } from '../compiler/compile-style.js';
|
||||
@ -12,9 +12,9 @@ import { compileBundles } from '../compiler/compile-bundles.js';
|
||||
import { genPackageEntry } from '../compiler/gen-package-entry.js';
|
||||
import { genStyleDepsMap } from '../compiler/gen-style-deps-map.js';
|
||||
import { genComponentStyle } from '../compiler/gen-component-style.js';
|
||||
import { SRC_DIR, LIB_DIR, ES_DIR } from '../common/constant.js';
|
||||
import { SRC_DIR, LIB_DIR, ES_DIR, getVantConfig } from '../common/constant.js';
|
||||
import { genPackageStyle } from '../compiler/gen-package-style.js';
|
||||
import { genVeturConfig } from '../compiler/gen-vetur-config.js';
|
||||
import { genWebStormTypes } from '../compiler/web-types/index.js';
|
||||
import {
|
||||
isDir,
|
||||
isSfc,
|
||||
@ -135,9 +135,10 @@ async function buildPackageStyleEntry() {
|
||||
}
|
||||
|
||||
async function buildBundledOutputs() {
|
||||
const config = getVantConfig();
|
||||
setModuleEnv('esmodule');
|
||||
await compileBundles();
|
||||
genVeturConfig();
|
||||
genWebStormTypes(config.build?.tagPrefix);
|
||||
}
|
||||
|
||||
const tasks = [
|
||||
@ -178,14 +179,14 @@ const tasks = [
|
||||
async function runBuildTasks() {
|
||||
for (let i = 0; i < tasks.length; i++) {
|
||||
const { task, text } = tasks[i];
|
||||
const spinner = ora(text).start();
|
||||
const spinner = createSpinner(text).start();
|
||||
|
||||
try {
|
||||
/* eslint-disable no-await-in-loop */
|
||||
await task();
|
||||
spinner.succeed(text);
|
||||
spinner.success({ text });
|
||||
} catch (err) {
|
||||
spinner.fail(text);
|
||||
spinner.error({ text });
|
||||
console.log(err);
|
||||
throw err;
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { join, dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { ROOT } from '../common/constant.js';
|
||||
import { ora, slimPath } from '../common/logger.js';
|
||||
import { createSpinner, slimPath } from '../common/logger.js';
|
||||
import { createWriteStream, readFileSync } from 'fs';
|
||||
import conventionalChangelog from 'conventional-changelog';
|
||||
|
||||
@ -48,7 +48,7 @@ function transform(item: any) {
|
||||
}
|
||||
|
||||
export async function changelog(): Promise<void> {
|
||||
const spinner = ora('Generating changelog...').start();
|
||||
const spinner = createSpinner('Generating changelog...').start();
|
||||
|
||||
return new Promise((resolve) => {
|
||||
conventionalChangelog(
|
||||
@ -68,7 +68,9 @@ export async function changelog(): Promise<void> {
|
||||
)
|
||||
.pipe(createWriteStream(DIST_FILE))
|
||||
.on('close', () => {
|
||||
spinner.succeed(`Changelog generated at ${slimPath(DIST_FILE)}`);
|
||||
spinner.success({
|
||||
text: `Changelog generated at ${slimPath(DIST_FILE)}`,
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
@ -3,7 +3,6 @@ import {
|
||||
ES_DIR,
|
||||
LIB_DIR,
|
||||
DIST_DIR,
|
||||
VETUR_DIR,
|
||||
SITE_DIST_DIR,
|
||||
} from '../common/constant.js';
|
||||
|
||||
@ -14,7 +13,6 @@ export async function clean() {
|
||||
remove(ES_DIR),
|
||||
remove(LIB_DIR),
|
||||
remove(DIST_DIR),
|
||||
remove(VETUR_DIR),
|
||||
remove(SITE_DIST_DIR),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import execa from 'execa';
|
||||
import { consola, ora } from '../common/logger.js';
|
||||
import { consola, createSpinner } from '../common/logger.js';
|
||||
import { SCRIPT_EXTS } from '../common/constant.js';
|
||||
|
||||
type RunCommandMessages = {
|
||||
@ -13,7 +13,7 @@ function runCommand(
|
||||
options: string[],
|
||||
messages: RunCommandMessages
|
||||
) {
|
||||
const spinner = ora(messages.start).start();
|
||||
const spinner = createSpinner(messages.start).start();
|
||||
|
||||
return new Promise((resolve) => {
|
||||
execa(cmd, options, {
|
||||
@ -21,11 +21,11 @@ function runCommand(
|
||||
env: { FORCE_COLOR: true },
|
||||
})
|
||||
.then(() => {
|
||||
spinner.succeed(messages.succeed);
|
||||
spinner.success({ text: messages.succeed });
|
||||
resolve(true);
|
||||
})
|
||||
.catch((err: any) => {
|
||||
spinner.fail(messages.failed);
|
||||
spinner.error({ text: messages.failed });
|
||||
consola.error(err.stderr || err.stdout);
|
||||
resolve(false);
|
||||
});
|
||||
@ -44,23 +44,10 @@ function eslint() {
|
||||
);
|
||||
}
|
||||
|
||||
function stylelint() {
|
||||
return runCommand(
|
||||
'stylelint',
|
||||
['src/**/*.css', 'src/**/*.vue', 'src/**/*.less', 'src/**/*.sass', '--fix'],
|
||||
{
|
||||
start: 'Running stylelint...',
|
||||
succeed: 'Stylelint Passed.',
|
||||
failed: 'Stylelint failed!',
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export async function lint() {
|
||||
const eslintPassed = await eslint();
|
||||
const stylelintPassed = await stylelint();
|
||||
|
||||
if (!eslintPassed || !stylelintPassed) {
|
||||
if (!eslintPassed) {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ import { join, dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const PLUGIN_PATH = join(__dirname, '../../cjs/vant-cli-release-plugin.cjs');
|
||||
const PLUGIN_PATH = join(__dirname, '../compiler/vant-cli-release-plugin.js');
|
||||
|
||||
export async function release(command: { tag?: string }) {
|
||||
await releaseIt({
|
||||
|
||||
@ -21,7 +21,6 @@ export const ROOT = findRootDir(CWD);
|
||||
export const ES_DIR = join(ROOT, 'es');
|
||||
export const LIB_DIR = join(ROOT, 'lib');
|
||||
export const DOCS_DIR = join(ROOT, 'docs');
|
||||
export const VETUR_DIR = join(ROOT, 'vetur');
|
||||
export const SITE_DIST_DIR = join(ROOT, 'site-dist');
|
||||
export const VANT_CONFIG_FILE = join(ROOT, 'vant.config.mjs');
|
||||
export const PACKAGE_JSON_FILE = join(ROOT, 'package.json');
|
||||
@ -43,7 +42,15 @@ export const STYLE_DEPS_JSON_FILE = join(DIST_DIR, 'style-deps.json');
|
||||
export const POSTCSS_CONFIG_FILE = join(CJS_DIR, 'postcss.config.cjs');
|
||||
export const JEST_CONFIG_FILE = join(CJS_DIR, 'jest.config.cjs');
|
||||
|
||||
export const SCRIPT_EXTS = ['.js', '.jsx', '.vue', '.ts', '.tsx'];
|
||||
export const SCRIPT_EXTS = [
|
||||
'.js',
|
||||
'.jsx',
|
||||
'.vue',
|
||||
'.ts',
|
||||
'.tsx',
|
||||
'.mjs',
|
||||
'.cjs',
|
||||
];
|
||||
export const STYLE_EXTS = ['.css', '.less', '.scss'];
|
||||
|
||||
export function getPackageJson() {
|
||||
|
||||
@ -72,7 +72,7 @@ export function pascalize(str: string): string {
|
||||
export function decamelize(str: string, sep = '-') {
|
||||
return str
|
||||
.replace(/([a-z\d])([A-Z])/g, '$1' + sep + '$2')
|
||||
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + sep + '$2')
|
||||
.replace(/([A-Z])([A-Z][a-z\d]+)/g, '$1' + sep + '$2')
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import ora from 'ora';
|
||||
import chalk from 'chalk';
|
||||
import { createSpinner } from 'nanospinner';
|
||||
import color from 'picocolors';
|
||||
import consola from 'consola';
|
||||
import { ROOT } from '../common/constant.js';
|
||||
|
||||
export function slimPath(path: string) {
|
||||
return chalk.yellow(path.replace(ROOT, ''));
|
||||
return color.yellow(path.replace(ROOT, ''));
|
||||
}
|
||||
|
||||
export { ora, consola };
|
||||
export { createSpinner, consola };
|
||||
|
||||
@ -1,68 +1,41 @@
|
||||
import fse from 'fs-extra';
|
||||
import { join } from 'path';
|
||||
import { build } from 'vite';
|
||||
import { getPackageJson, getVantConfig, LIB_DIR } from '../common/constant.js';
|
||||
import { getPackageJson, getVantConfig } from '../common/constant.js';
|
||||
import { mergeCustomViteConfig } from '../common/index.js';
|
||||
import { getViteConfigForPackage } from '../config/vite.package.js';
|
||||
import type { LibraryFormats } from 'vite';
|
||||
|
||||
// generate entry file for nuxt
|
||||
async function genEntryForSSR() {
|
||||
const { name } = getVantConfig();
|
||||
const cjsPath = join(LIB_DIR, 'ssr.js');
|
||||
const mjsPath = join(LIB_DIR, 'ssr.mjs');
|
||||
|
||||
const cjsContent = `'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./${name}.cjs.min.js');
|
||||
} else {
|
||||
module.exports = require('./${name}.cjs.js');
|
||||
export type BundleOption = {
|
||||
minify?: boolean;
|
||||
formats: LibraryFormats[];
|
||||
external?: string[];
|
||||
};
|
||||
`;
|
||||
|
||||
const mjsContent = `export * from './index.js';\n`;
|
||||
|
||||
return Promise.all([
|
||||
fse.outputFile(cjsPath, cjsContent),
|
||||
fse.outputFile(mjsPath, mjsContent),
|
||||
]);
|
||||
}
|
||||
|
||||
export async function compileBundles() {
|
||||
const dependencies = getPackageJson().dependencies || {};
|
||||
const externals = Object.keys(dependencies);
|
||||
const external = Object.keys(dependencies);
|
||||
|
||||
const configs = [
|
||||
// umd bundle
|
||||
getViteConfigForPackage({
|
||||
const DEFAULT_OPTIONS: BundleOption[] = [
|
||||
{
|
||||
minify: false,
|
||||
formats: ['umd'],
|
||||
external: ['vue'],
|
||||
}),
|
||||
// umd bundle (minified)
|
||||
getViteConfigForPackage({
|
||||
},
|
||||
{
|
||||
minify: true,
|
||||
formats: ['umd'],
|
||||
external: ['vue'],
|
||||
}),
|
||||
// esm/cjs bundle
|
||||
getViteConfigForPackage({
|
||||
},
|
||||
{
|
||||
minify: false,
|
||||
formats: ['es', 'cjs'],
|
||||
external: ['vue', ...externals],
|
||||
}),
|
||||
// esm/cjs bundle (minified)
|
||||
// vite will not minify es bundle
|
||||
// see: https://github.com/vuejs/vue-next/issues/2860
|
||||
getViteConfigForPackage({
|
||||
minify: true,
|
||||
formats: ['es', 'cjs'],
|
||||
external: ['vue', ...externals],
|
||||
}),
|
||||
external,
|
||||
},
|
||||
];
|
||||
|
||||
const bundleOptions: BundleOption[] =
|
||||
getVantConfig().build?.bundleOptions || DEFAULT_OPTIONS;
|
||||
|
||||
await Promise.all(
|
||||
configs.map((config) => build(mergeCustomViteConfig(config)))
|
||||
bundleOptions.map((config) =>
|
||||
build(mergeCustomViteConfig(getViteConfigForPackage(config)))
|
||||
)
|
||||
);
|
||||
await genEntryForSSR();
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ import fse from 'fs-extra';
|
||||
import babel from '@babel/core';
|
||||
import esbuild, { type Format } from 'esbuild';
|
||||
import { sep } from 'path';
|
||||
import { isJsx, replaceExt } from '../common/index.js';
|
||||
import { isJsx, replaceExt, getVantConfig } from '../common/index.js';
|
||||
import { replaceCSSImportExt } from '../common/css.js';
|
||||
import { replaceScriptImportExt } from './get-deps.js';
|
||||
|
||||
@ -16,12 +16,15 @@ export async function compileScript(
|
||||
return;
|
||||
}
|
||||
|
||||
const extensionMap = getVantConfig().build?.extensions;
|
||||
const extension = extensionMap?.[format] || '.js';
|
||||
|
||||
let code = readFileSync(filePath, 'utf-8');
|
||||
|
||||
if (!filePath.includes(`${sep}style${sep}`)) {
|
||||
code = replaceCSSImportExt(code);
|
||||
}
|
||||
code = replaceScriptImportExt(code, '.vue', '');
|
||||
code = replaceScriptImportExt(code, filePath, extension);
|
||||
|
||||
if (isJsx(filePath)) {
|
||||
const babelResult = await babel.transformAsync(code, {
|
||||
@ -50,7 +53,8 @@ export async function compileScript(
|
||||
|
||||
({ code } = esbuildResult);
|
||||
|
||||
const jsFilePath = replaceExt(filePath, '.js');
|
||||
const jsFilePath = replaceExt(filePath, extension);
|
||||
|
||||
removeSync(filePath);
|
||||
outputFileSync(jsFilePath, code);
|
||||
}
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
import fse from 'fs-extra';
|
||||
import path from 'path';
|
||||
import hash from 'hash-sum';
|
||||
import { parse, SFCBlock, compileTemplate } from 'vue/compiler-sfc';
|
||||
import {
|
||||
parse,
|
||||
SFCBlock,
|
||||
compileTemplate,
|
||||
compileScript,
|
||||
} from 'vue/compiler-sfc';
|
||||
import { replaceExt } from '../common/index.js';
|
||||
|
||||
const { remove, readFileSync, outputFile } = fse;
|
||||
@ -73,20 +78,26 @@ export async function compileSfc(filePath: string): Promise<any> {
|
||||
const scopeId = hasScoped ? `data-v-${hash(source)}` : '';
|
||||
|
||||
// compile js part
|
||||
if (descriptor.script) {
|
||||
const lang = descriptor.script.lang || 'js';
|
||||
if (descriptor.script || descriptor.scriptSetup) {
|
||||
const lang =
|
||||
descriptor.script?.lang || descriptor.scriptSetup?.lang || 'js';
|
||||
const scriptFilePath = replaceExt(filePath, `.${lang}`);
|
||||
|
||||
tasks.push(
|
||||
new Promise((resolve) => {
|
||||
let script = '';
|
||||
|
||||
// the generated render fn lacks type definitions
|
||||
if (lang === 'ts') {
|
||||
script += '// @ts-nocheck\n';
|
||||
let bindingMetadata;
|
||||
if (descriptor.scriptSetup) {
|
||||
const { bindings, content } = compileScript(descriptor, {
|
||||
id: scopeId,
|
||||
});
|
||||
script += content;
|
||||
bindingMetadata = bindings;
|
||||
} else {
|
||||
script += descriptor.script!.content;
|
||||
}
|
||||
|
||||
script += descriptor.script!.content;
|
||||
script = injectStyle(script, styles, filePath);
|
||||
script = script.replace(EXPORT, `const ${VUEIDS} =`);
|
||||
|
||||
@ -95,6 +106,9 @@ export async function compileSfc(filePath: string): Promise<any> {
|
||||
id: scopeId,
|
||||
source: template.content,
|
||||
filename: filePath,
|
||||
compilerOptions: {
|
||||
bindingMetadata,
|
||||
},
|
||||
}).code;
|
||||
|
||||
script = injectRender(script, render);
|
||||
@ -106,6 +120,12 @@ export async function compileSfc(filePath: string): Promise<any> {
|
||||
|
||||
script += `\n${EXPORT} ${VUEIDS}`;
|
||||
|
||||
// ts-nocheck should be placed on the first line
|
||||
// the generated render fn lacks type definitions
|
||||
if (lang === 'ts') {
|
||||
script = '// @ts-nocheck\n' + script;
|
||||
}
|
||||
|
||||
outputFile(scriptFilePath, script).then(resolve);
|
||||
})
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import chalk from 'chalk';
|
||||
import color from 'picocolors';
|
||||
import { createRequire } from 'module';
|
||||
import { createServer, build } from 'vite';
|
||||
import {
|
||||
@ -38,8 +38,8 @@ export async function compileSite(production = false) {
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { version } = require('vite/package.json');
|
||||
const viteInfo = chalk.cyan(`vite v${version}`);
|
||||
console.log(`\n ${viteInfo}` + chalk.green(` dev server running at:\n`));
|
||||
const viteInfo = color.cyan(`vite v${version}`);
|
||||
console.log(`\n ${viteInfo}` + color.green(` dev server running at:\n`));
|
||||
server.printUrls();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
import { parse } from 'path';
|
||||
import { readFileSync, writeFileSync } from 'fs';
|
||||
import { replaceExt } from '../common/index.js';
|
||||
import fse from 'fs-extra';
|
||||
import { getVantConfig, replaceExt } from '../common/index.js';
|
||||
import { compileCss } from './compile-css.js';
|
||||
import { compileLess } from './compile-less.js';
|
||||
import { compileSass } from './compile-sass.js';
|
||||
import { consola } from '../common/logger.js';
|
||||
|
||||
const { readFileSync, writeFileSync, removeSync } = fse;
|
||||
|
||||
async function compileFile(filePath: string) {
|
||||
const parsedPath = parse(filePath);
|
||||
|
||||
@ -30,6 +32,11 @@ async function compileFile(filePath: string) {
|
||||
|
||||
export async function compileStyle(filePath: string) {
|
||||
const css = await compileFile(filePath);
|
||||
const vantConfig = getVantConfig();
|
||||
|
||||
if (vantConfig.build?.css?.removeSourceFile) {
|
||||
removeSync(filePath);
|
||||
}
|
||||
|
||||
writeFileSync(replaceExt(filePath, '.css'), css);
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import {
|
||||
ES_DIR,
|
||||
SRC_DIR,
|
||||
LIB_DIR,
|
||||
getVantConfig,
|
||||
STYLE_DEPS_JSON_FILE,
|
||||
} from '../common/constant.js';
|
||||
|
||||
@ -87,8 +88,10 @@ export function genComponentStyle(
|
||||
delete require.cache[STYLE_DEPS_JSON_FILE];
|
||||
}
|
||||
|
||||
const vantConfig = getVantConfig();
|
||||
const components = getComponents();
|
||||
const baseFile = getCssBaseFile();
|
||||
const hasSourceFile = vantConfig.build?.css?.removeSourceFile !== true;
|
||||
|
||||
components.forEach((component) => {
|
||||
genEntry({
|
||||
@ -98,7 +101,7 @@ export function genComponentStyle(
|
||||
ext: '.css',
|
||||
});
|
||||
|
||||
if (CSS_LANG !== 'css') {
|
||||
if (CSS_LANG !== 'css' && hasSourceFile) {
|
||||
genEntry({
|
||||
baseFile,
|
||||
component,
|
||||
|
||||
@ -22,7 +22,7 @@ export function checkStyleExists(component: string) {
|
||||
// analyze component dependencies
|
||||
function analyzeComponentDeps(components: string[], component: string) {
|
||||
const checkList: string[] = [];
|
||||
const componentEntry = fillExt(join(SRC_DIR, component, 'index'));
|
||||
const componentEntry = fillExt(join(SRC_DIR, component, 'index')).path;
|
||||
const record = new Set();
|
||||
|
||||
function search(filePath: string) {
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
import markdownVetur from '@vant/markdown-vetur';
|
||||
import {
|
||||
SRC_DIR,
|
||||
VETUR_DIR,
|
||||
getVantConfig,
|
||||
getPackageJson,
|
||||
} from '../common/constant.js';
|
||||
|
||||
// generate vetur tags & attributes
|
||||
export function genVeturConfig() {
|
||||
const pkgJson = getPackageJson();
|
||||
const vantConfig = getVantConfig();
|
||||
const options = vantConfig.build?.vetur;
|
||||
|
||||
if (options) {
|
||||
markdownVetur.parseAndWrite({
|
||||
name: vantConfig.name,
|
||||
path: SRC_DIR,
|
||||
test: /README\.md/,
|
||||
version: pkgJson.version,
|
||||
outputDir: VETUR_DIR,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
import { join } from 'path';
|
||||
import { SCRIPT_EXTS } from '../common/constant.js';
|
||||
import { SCRIPT_EXTS, STYLE_EXTS } from '../common/constant.js';
|
||||
import { readFileSync, existsSync } from 'fs';
|
||||
|
||||
let depsMap: Record<string, string[]> = {};
|
||||
@ -8,12 +8,19 @@ let existsCache: Record<string, boolean> = {};
|
||||
// https://regexr.com/47jlq
|
||||
const IMPORT_RE =
|
||||
/import\s+?(?:(?:(?:[\w*\s{},]*)\s+from(\s+)?)|)(?:(?:".*?")|(?:'.*?'))[\s]*?(?:;|$|)/g;
|
||||
const EXPORT_FROM_RE =
|
||||
/@?export\s+?(?:(?:(?:[\w*\s{},]*)\s+from(\s+)?)|)(?:(?:".*?")|(?:'.*?'))[\s]*?(?:;|$|)/g;
|
||||
|
||||
function matchImports(code: string): string[] {
|
||||
const imports = code.match(IMPORT_RE) || [];
|
||||
return imports.filter((line) => !line.includes('import type'));
|
||||
}
|
||||
|
||||
function matchExportFroms(code: string): string[] {
|
||||
const exportFroms = code.match(EXPORT_FROM_RE) || [];
|
||||
return exportFroms.filter((line) => !line.includes('export type'));
|
||||
}
|
||||
|
||||
function exists(filePath: string) {
|
||||
if (!(filePath in existsCache)) {
|
||||
existsCache[filePath] = existsSync(filePath);
|
||||
@ -26,23 +33,36 @@ export function fillExt(filePath: string) {
|
||||
for (let i = 0; i < SCRIPT_EXTS.length; i++) {
|
||||
const completePath = `${filePath}${SCRIPT_EXTS[i]}`;
|
||||
if (exists(completePath)) {
|
||||
return completePath;
|
||||
return {
|
||||
path: completePath,
|
||||
isIndex: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < SCRIPT_EXTS.length; i++) {
|
||||
const completePath = `${filePath}/index${SCRIPT_EXTS[i]}`;
|
||||
if (exists(completePath)) {
|
||||
return completePath;
|
||||
return {
|
||||
path: completePath,
|
||||
isIndex: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
return {
|
||||
path: '',
|
||||
isIndex: false,
|
||||
};
|
||||
}
|
||||
|
||||
function getImportRelativePath(code: string) {
|
||||
const divider = code.includes('"') ? '"' : "'";
|
||||
return code.split(divider)[1];
|
||||
}
|
||||
|
||||
function getPathByImport(code: string, filePath: string) {
|
||||
const divider = code.includes('"') ? '"' : "'";
|
||||
const relativePath = code.split(divider)[1];
|
||||
const relativePath = getImportRelativePath(code);
|
||||
|
||||
if (relativePath.includes('.')) {
|
||||
return fillExt(join(filePath, '..', relativePath));
|
||||
@ -64,7 +84,7 @@ export function getDeps(filePath: string) {
|
||||
const code = readFileSync(filePath, 'utf-8');
|
||||
const imports = matchImports(code);
|
||||
const paths = imports
|
||||
.map((item) => getPathByImport(item, filePath))
|
||||
.map((item) => getPathByImport(item, filePath)?.path)
|
||||
.filter((item) => !!item) as string[];
|
||||
|
||||
depsMap[filePath] = paths;
|
||||
@ -74,14 +94,58 @@ export function getDeps(filePath: string) {
|
||||
return paths;
|
||||
}
|
||||
|
||||
// "import App from 'App.vue';" => "import App from 'App.xxx';"
|
||||
export function replaceScriptImportExt(code: string, from: string, to: string) {
|
||||
const importLines = matchImports(code);
|
||||
/**
|
||||
* 1. Replace .vue extension
|
||||
* @example "import App from 'App.vue';" => "import App from 'App.xxx';"
|
||||
*
|
||||
* 2. if using .mjs or .cjs, complete the import path
|
||||
* @example import './foo' -> import './foo.mjs'
|
||||
* @example import './foo' -> import './foo/index.mjs'
|
||||
*/
|
||||
export function replaceScriptImportExt(
|
||||
code: string,
|
||||
filePath: string,
|
||||
ext: string
|
||||
) {
|
||||
const imports = [...matchImports(code), ...matchExportFroms(code)];
|
||||
|
||||
importLines.forEach((importLine) => {
|
||||
const result = importLine.replace(from, to);
|
||||
code = code.replace(importLine, result);
|
||||
const updateImport = (index: number, newImport: string) => {
|
||||
code = code.replace(imports[index], newImport);
|
||||
imports[index] = newImport;
|
||||
};
|
||||
|
||||
imports.forEach((line, index) => {
|
||||
if (line.includes('.vue')) {
|
||||
updateImport(index, line.replace('.vue', ext));
|
||||
}
|
||||
});
|
||||
|
||||
if (ext === '.mjs' || ext === '.cjs') {
|
||||
imports.forEach((line, index) => {
|
||||
const isStyleImport = STYLE_EXTS.some((ext) => line.includes(ext));
|
||||
if (isStyleImport) {
|
||||
return;
|
||||
}
|
||||
|
||||
const pathInfo = getPathByImport(line, filePath);
|
||||
|
||||
if (pathInfo) {
|
||||
const relativePath = getImportRelativePath(line);
|
||||
|
||||
if (pathInfo.isIndex) {
|
||||
const newLine = line.replace(
|
||||
relativePath,
|
||||
`${relativePath}/index${ext}`
|
||||
);
|
||||
|
||||
updateImport(index, newLine);
|
||||
} else {
|
||||
const newLine = line.replace(relativePath, relativePath + ext);
|
||||
updateImport(index, newLine);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
const releaseIt = require('release-it');
|
||||
const { execSync } = require('child_process');
|
||||
import { Plugin } from 'release-it';
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
class VantCliReleasePlugin extends releaseIt.Plugin {
|
||||
class VantCliReleasePlugin extends Plugin {
|
||||
async beforeRelease() {
|
||||
// log an empty line
|
||||
console.log('');
|
||||
@ -11,4 +11,4 @@ class VantCliReleasePlugin extends releaseIt.Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = VantCliReleasePlugin;
|
||||
export default VantCliReleasePlugin;
|
||||
@ -1,12 +1,55 @@
|
||||
/* eslint-disable no-continue */
|
||||
import { Articals } from './parser';
|
||||
import { formatOptions, formatType, removeVersion, toKebabCase } from './utils';
|
||||
import { VueTag } from './type';
|
||||
import { Articles } from './parser.js';
|
||||
import {
|
||||
formatOptions,
|
||||
formatType,
|
||||
removeVersion,
|
||||
toKebabCase,
|
||||
} from './utils.js';
|
||||
import { VueEventArgument, VueTag } from './type.js';
|
||||
|
||||
function formatComponentName(name: string, tagPrefix: string) {
|
||||
return tagPrefix + toKebabCase(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* format arguments of events
|
||||
* input = value: { foo: foo or 1, bar: bar or 2 }, value2: { one: 1 and 1, two: 2 and 2 }, foo: bar
|
||||
* output = [{ name: 'value', type: '{ foo: foo or 1, bar: bar or 2 }' }, { name: 'value2', type: '{ one: 1 and 1, two: 2 and 2 }'}, { name: 'foo', type: 'bar' }]
|
||||
*/
|
||||
function formatArguments(input: string): VueEventArgument[] {
|
||||
if (input === '-') return [];
|
||||
const args: VueEventArgument[] = [];
|
||||
const items = [];
|
||||
input = formatType(input);
|
||||
while (input.length > 0) {
|
||||
if (/(?!_)\w/.test(input[0])) {
|
||||
const val = input.match(/(\w|\s|\p{P}|\||\[|\]|>|<)+/)![0] || '';
|
||||
input = input.substring(val.length);
|
||||
items.push(val);
|
||||
} else if (input[0] === '{') {
|
||||
const val = input.match(/\{[^}]+\}/)![0] || '';
|
||||
input = input.substring(val.length);
|
||||
items.push(val);
|
||||
} else if ([':', ',', '_', ' '].includes(input[0])) {
|
||||
input = input.substring(1);
|
||||
} else {
|
||||
const val = input.match(/( |'|\||\w)+/)![0] || '';
|
||||
input = input.substring(val.length);
|
||||
items.push(val);
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < items.length; i += 2) {
|
||||
args.push({
|
||||
name: items[i],
|
||||
type: items[i + 1],
|
||||
});
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
function getNameFromTableTitle(tableTitle: string, tagPrefix: string) {
|
||||
tableTitle = tableTitle.trim();
|
||||
if (tableTitle.includes(' ')) {
|
||||
@ -35,29 +78,29 @@ function findTag(vueTags: VueTag[], name: string) {
|
||||
|
||||
export function formatter(
|
||||
vueTags: VueTag[],
|
||||
articals: Articals,
|
||||
articles: Articles,
|
||||
tagPrefix = ''
|
||||
) {
|
||||
if (!articals.length) {
|
||||
if (!articles.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const mainTitle = articals[0].content;
|
||||
const mainTitle = articles[0].content;
|
||||
const defaultName = mainTitle
|
||||
? formatComponentName(mainTitle.split(' ')[0], tagPrefix)
|
||||
: '';
|
||||
const tables = articals.filter((artical) => artical.type === 'table');
|
||||
const tables = articles.filter((article) => article.type === 'table');
|
||||
|
||||
tables.forEach((item) => {
|
||||
const { table } = item;
|
||||
const prevIndex = articals.indexOf(item) - 1;
|
||||
const prevArtical = articals[prevIndex];
|
||||
const prevIndex = articles.indexOf(item) - 1;
|
||||
const prevArticle = articles[prevIndex];
|
||||
|
||||
if (!prevArtical || !prevArtical.content || !table || !table.body) {
|
||||
if (!prevArticle || !prevArticle.content || !table || !table.body) {
|
||||
return;
|
||||
}
|
||||
|
||||
const tableTitle = prevArtical.content;
|
||||
const tableTitle = prevArticle.content;
|
||||
|
||||
if (tableTitle.includes('Props')) {
|
||||
const name = getNameFromTableTitle(tableTitle, tagPrefix) || defaultName;
|
||||
@ -84,10 +127,11 @@ export function formatter(
|
||||
const tag = findTag(vueTags, name);
|
||||
|
||||
table.body.forEach((line) => {
|
||||
const [name, desc] = line;
|
||||
const [name, desc, args] = line;
|
||||
tag.events!.push({
|
||||
name: removeVersion(name),
|
||||
description: desc,
|
||||
arguments: formatArguments(args),
|
||||
});
|
||||
});
|
||||
return;
|
||||
55
packages/vant-cli/src/compiler/web-types/index.ts
Normal file
55
packages/vant-cli/src/compiler/web-types/index.ts
Normal file
@ -0,0 +1,55 @@
|
||||
import glob from 'fast-glob';
|
||||
import { join } from 'path';
|
||||
import fse from 'fs-extra';
|
||||
import { mdParser } from './parser.js';
|
||||
import { formatter } from './formatter.js';
|
||||
import { genWebTypes } from './web-types.js';
|
||||
import { Options, VueTag } from './type.js';
|
||||
import { normalizePath } from './utils.js';
|
||||
import {
|
||||
SRC_DIR,
|
||||
LIB_DIR,
|
||||
getVantConfig,
|
||||
getPackageJson,
|
||||
} from '../../common/constant.js';
|
||||
|
||||
async function readMarkdown(options: Options) {
|
||||
const mds = await glob(normalizePath(`${options.path}/**/*.md`));
|
||||
return mds
|
||||
.filter((md) => options.test.test(md))
|
||||
.map((path) => fse.readFileSync(path, 'utf-8'));
|
||||
}
|
||||
|
||||
export async function parseAndWrite(options: Options) {
|
||||
if (!options.outputDir) {
|
||||
throw new Error('outputDir can not be empty.');
|
||||
}
|
||||
|
||||
const mds = await readMarkdown(options);
|
||||
const vueTags: VueTag[] = [];
|
||||
|
||||
mds.forEach((md) => {
|
||||
const parsedMd = mdParser(md);
|
||||
formatter(vueTags, parsedMd, options.tagPrefix);
|
||||
});
|
||||
|
||||
const webTypes = genWebTypes(vueTags, options);
|
||||
fse.outputFileSync(
|
||||
join(options.outputDir, 'web-types.json'),
|
||||
JSON.stringify(webTypes, null, 2)
|
||||
);
|
||||
}
|
||||
|
||||
export function genWebStormTypes(tagPrefix?: string) {
|
||||
const pkgJson = getPackageJson();
|
||||
const vantConfig = getVantConfig();
|
||||
|
||||
parseAndWrite({
|
||||
name: vantConfig.name,
|
||||
path: SRC_DIR,
|
||||
test: /README\.md/,
|
||||
version: pkgJson.version,
|
||||
outputDir: LIB_DIR,
|
||||
tagPrefix,
|
||||
});
|
||||
}
|
||||
@ -9,14 +9,14 @@ type TableContent = {
|
||||
body: string[][];
|
||||
};
|
||||
|
||||
export type Artical = {
|
||||
export type Article = {
|
||||
type: string;
|
||||
content?: string;
|
||||
table?: TableContent;
|
||||
level?: number;
|
||||
};
|
||||
|
||||
export type Articals = Artical[];
|
||||
export type Articles = Article[];
|
||||
|
||||
function readLine(input: string) {
|
||||
const end = input.indexOf('\n');
|
||||
@ -25,9 +25,11 @@ function readLine(input: string) {
|
||||
}
|
||||
|
||||
function splitTableLine(line: string) {
|
||||
line = line.replace('\\|', 'JOIN');
|
||||
line = line.replace(/\\\|/g, 'JOIN');
|
||||
|
||||
const items = line.split('|').map((item) => item.trim().replace('JOIN', '|'));
|
||||
const items = line
|
||||
.split('|')
|
||||
.map((item) => item.trim().replace(/JOIN/g, '|'));
|
||||
|
||||
// remove pipe character on both sides
|
||||
items.pop();
|
||||
@ -73,8 +75,8 @@ function tableParse(input: string) {
|
||||
};
|
||||
}
|
||||
|
||||
export function mdParser(input: string): Articals {
|
||||
const artical = [];
|
||||
export function mdParser(input: string): Articles {
|
||||
const article = [];
|
||||
let start = 0;
|
||||
const end = input.length;
|
||||
|
||||
@ -83,7 +85,7 @@ export function mdParser(input: string): Articals {
|
||||
|
||||
let match;
|
||||
if ((match = TITLE_REG.exec(target))) {
|
||||
artical.push({
|
||||
article.push({
|
||||
type: 'title',
|
||||
content: match[2],
|
||||
level: match[1].length,
|
||||
@ -92,7 +94,7 @@ export function mdParser(input: string): Articals {
|
||||
start += match.index + match[0].length;
|
||||
} else if ((match = TABLE_REG.exec(target))) {
|
||||
const { table, usedLength } = tableParse(target.substr(match.index));
|
||||
artical.push({
|
||||
article.push({
|
||||
type: 'table',
|
||||
table,
|
||||
});
|
||||
@ -103,5 +105,5 @@ export function mdParser(input: string): Articals {
|
||||
}
|
||||
}
|
||||
|
||||
return artical;
|
||||
return article;
|
||||
}
|
||||
@ -35,26 +35,6 @@ export type VueTag = {
|
||||
description?: string;
|
||||
};
|
||||
|
||||
export type VeturTag = {
|
||||
description?: string;
|
||||
attributes: string[];
|
||||
};
|
||||
|
||||
export type VeturTags = Record<string, VeturTag>;
|
||||
|
||||
export type VeturAttribute = {
|
||||
type: string;
|
||||
description: string;
|
||||
options?: string[];
|
||||
};
|
||||
|
||||
export type VeturAttributes = Record<string, VeturAttribute>;
|
||||
|
||||
export type VeturResult = {
|
||||
tags: VeturTags;
|
||||
attributes: VeturAttributes;
|
||||
};
|
||||
|
||||
export type Options = {
|
||||
name: string;
|
||||
path: PathLike;
|
||||
@ -1,4 +1,4 @@
|
||||
import { VueTag, Options } from './type';
|
||||
import type { VueTag, Options } from './type.js';
|
||||
|
||||
// create web-types.json to provide autocomplete in JetBrains IDEs
|
||||
export function genWebTypes(tags: VueTag[], options: Options) {
|
||||
@ -1,40 +1,47 @@
|
||||
import { join } from 'path';
|
||||
import { setBuildTarget } from '../common/index.js';
|
||||
import { CWD, ES_DIR, getVantConfig, LIB_DIR } from '../common/constant.js';
|
||||
import type { InlineConfig, LibraryFormats } from 'vite';
|
||||
import type { InlineConfig } from 'vite';
|
||||
import type { BundleOption } from '../compiler/compile-bundles.js';
|
||||
|
||||
export function getViteConfigForPackage({
|
||||
minify,
|
||||
formats,
|
||||
external,
|
||||
}: {
|
||||
minify: boolean;
|
||||
formats: LibraryFormats[];
|
||||
external: string[];
|
||||
}): InlineConfig {
|
||||
external = [],
|
||||
}: BundleOption): InlineConfig {
|
||||
setBuildTarget('package');
|
||||
|
||||
const { name } = getVantConfig();
|
||||
const { name, build } = getVantConfig();
|
||||
const entryExtension = build?.extensions?.esm || '.js';
|
||||
const entry = join(ES_DIR, `index${entryExtension}`);
|
||||
const shouldReplaceEnv = minify || formats?.includes('umd');
|
||||
|
||||
return {
|
||||
root: CWD,
|
||||
|
||||
logLevel: 'silent',
|
||||
|
||||
define: shouldReplaceEnv
|
||||
? {
|
||||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
||||
}
|
||||
: undefined,
|
||||
|
||||
build: {
|
||||
lib: {
|
||||
name,
|
||||
entry: join(ES_DIR, 'index.js'),
|
||||
entry,
|
||||
formats,
|
||||
fileName: (format: string) => {
|
||||
const suffix = format === 'umd' ? '' : `.${format}`;
|
||||
return minify ? `${name}${suffix}.min.js` : `${name}${suffix}.js`;
|
||||
},
|
||||
},
|
||||
|
||||
// terser has better compression than esbuild
|
||||
minify: minify ? 'terser' : false,
|
||||
rollupOptions: {
|
||||
external,
|
||||
external: [...external, 'vue'],
|
||||
output: {
|
||||
dir: LIB_DIR,
|
||||
exports: 'named',
|
||||
|
||||
@ -137,6 +137,7 @@ export function getViteConfigForSiteDev(): InlineConfig {
|
||||
const vantConfig = getVantConfig();
|
||||
const siteConfig = getSiteConfig(vantConfig);
|
||||
const title = getTitle(siteConfig);
|
||||
const headHtml = vantConfig.site?.headHtml;
|
||||
const baiduAnalytics = vantConfig.site?.baiduAnalytics;
|
||||
const enableVConsole = isDev() && vantConfig.site?.enableVConsole;
|
||||
|
||||
@ -178,6 +179,7 @@ export function getViteConfigForSiteDev(): InlineConfig {
|
||||
// `description` is used by the HTML ejs template,
|
||||
// so it needs to be written explicitly here to avoid error: description is not defined
|
||||
description: siteConfig.description,
|
||||
headHtml,
|
||||
baiduAnalytics,
|
||||
enableVConsole,
|
||||
meta: getHTMLMeta(vantConfig),
|
||||
@ -202,9 +204,9 @@ export function getViteConfigForSiteProd(): InlineConfig {
|
||||
base: publicPath,
|
||||
build: {
|
||||
outDir,
|
||||
brotliSize: false,
|
||||
reportCompressedSize: false,
|
||||
emptyOutDir: true,
|
||||
// https://github.com/youzan/vant/issues/9703
|
||||
// https://github.com/vant-ui/vant/issues/9703
|
||||
cssTarget: ['chrome53'],
|
||||
rollupOptions: {
|
||||
input: {
|
||||
|
||||
@ -1,30 +1,9 @@
|
||||
// @ts-ignore
|
||||
import fs from 'fs';
|
||||
import { URL, fileURLToPath } from 'url';
|
||||
import { dev } from './commands/dev.js';
|
||||
import { lint } from './commands/lint.js';
|
||||
import { test } from './commands/jest.js';
|
||||
import { clean } from './commands/clean.js';
|
||||
import { build } from './commands/build.js';
|
||||
import { release } from './commands/release.js';
|
||||
import { changelog } from './commands/changelog.js';
|
||||
import { buildSite } from './commands/build-site.js';
|
||||
import { commitLint } from './commands/commit-lint.js';
|
||||
|
||||
const packagePath = fileURLToPath(new URL('../package.json', import.meta.url));
|
||||
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8'));
|
||||
export const cliVersion: string = packageJson.version;
|
||||
|
||||
process.env.VANT_CLI_VERSION = cliVersion;
|
||||
|
||||
export {
|
||||
dev,
|
||||
lint,
|
||||
test,
|
||||
clean,
|
||||
build,
|
||||
release,
|
||||
changelog,
|
||||
buildSite,
|
||||
commitLint,
|
||||
};
|
||||
|
||||
2
packages/vant-cli/src/module.d.ts
vendored
2
packages/vant-cli/src/module.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
// some modules with missing type definitions
|
||||
declare module 'execa';
|
||||
declare module 'hash-sum';
|
||||
declare module '@babel/core';
|
||||
declare module 'release-it';
|
||||
declare module 'conventional-changelog';
|
||||
declare module '@vant/markdown-vetur';
|
||||
|
||||
@ -5,7 +5,31 @@
|
||||
{{~header}}
|
||||
{{~/if}}
|
||||
{{#if references~}}
|
||||
{{~#each references}} [{{~this.repository}}#{{this.issue}}]({{~@root.repoUrl}}/{{~@root.issue}}/{{this.issue}}){{/each}}
|
||||
{{~else}} [{{shortHash}}]({{~@root.repoUrl}}/{{~@root.commit}}/{{hash}})
|
||||
{{~#each references}} [{{~this.repository}}#{{this.issue}}](
|
||||
{{~#if @root.repository}}
|
||||
{{~#if @root.host}}
|
||||
{{~@root.host}}/
|
||||
{{~/if}}
|
||||
{{~#if @root.owner}}
|
||||
{{~@root.owner}}/
|
||||
{{~/if}}
|
||||
{{~@root.repository}}
|
||||
{{~else}}
|
||||
{{~@root.repoUrl}}
|
||||
{{~/if}}
|
||||
/{{~@root.issue}}/{{this.issue}}){{/each}}
|
||||
{{~else}} [{{shortHash}}](
|
||||
{{~#if @root.repository}}
|
||||
{{~#if @root.host}}
|
||||
{{~@root.host}}/
|
||||
{{~/if}}
|
||||
{{~#if @root.owner}}
|
||||
{{~@root.owner}}/
|
||||
{{~/if}}
|
||||
{{~@root.repository}}
|
||||
{{~else}}
|
||||
{{~@root.repoUrl}}
|
||||
{{~/if}}
|
||||
/{{~@root.commit}}/{{hash}})
|
||||
{{~/if}}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user