Skip to content

Commit

Permalink
docs: 更新 taro build 文章
Browse files Browse the repository at this point in the history
  • Loading branch information
ruochuan12 committed Aug 11, 2024
1 parent ee8d83e commit f35ae4f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/taro/cli-build/REAMDE.md → docs/taro/cli-build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,15 @@ async function checkConfig ({ projectConfig, helper }) {
}
```

Taro build 插件主要做了以下几件事:

- 判断 `config/index` 配置文件是否存在。
- 判断 `platfrom` 参数是否是字符串,这里是 `weapp`,如果不是,退出程序。
- 使用 `checkConfig` 函数校验配置文件 `config/index`,如果配置文件出错,退出程序。
- 调用 `ctx.applyPlugins(hooks.ON_BUILD_START)` (编译开始)钩子。
- 调用 `ctx.applyPlugins({ name: platform, })` (调用 weapp) 钩子。
- 调用 `ctx.applyPlugins(hooks.ON_BUILD_COMPLETE)` (编译结束)钩子。

```js
await ctx.applyPlugins({
name: platform,
Expand All @@ -198,6 +207,8 @@ await ctx.applyPlugins({

调用的是端平台插件,本文以微信小程序为例,所以调用的是 weapp。对应的源码文件路径是:`packages/taro-platform-weapp/src/index.ts`。我们来看具体实现。



## 端平台插件 weapp

```ts
Expand Down
1 change: 1 addition & 0 deletions docs/taro/cli-build/images/drawio/build-plugins.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile host="0baofar2q762guuegcsurkhdfj4suhhk07lh6r5taolql8cra09j" modified="2024-08-11T16:13:10.098Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Code/1.92.1 Chrome/124.0.6367.243 Electron/30.1.2 Safari/537.36" etag="yp458QpdxC-BXqTGInl9" version="12.2.4" pages="1"><diagram id="eLMFQpm0Jcj8squlpa35" name="Page-1">1ZPNboQgFIWfhr2CdZyt1pluurJJ11RuhQTFMDhqn75Y8C+2STdddGPgOwe4nIuIZPVw1bTlz4qBRDhgAyKPCOOHU2S/ExgdiILEgUoL5lC4gkJ8gIeBp51gcNsZjVLSiHYPS9U0UJodo1qrfm97V3J/aksrOICipPJIXwUz3NEEn1b+BKLi88lhfHZKTWezv8mNU6b6DSI5IplWyrhRPWQgp+zmXNy6yw/qUpiGxvxmAXYL7lR2/m4vVCuUxyi5oDNGeYTSFKWx9bx1wsbkqjbjHIVWXcNg2i1EJO25MFC0tJzU3vbeMm5q6eVjdb7gO2gDwwb5aq+gajB6tJZZnZNbno6b9msfFgvf9CD2jPrWV8vOazp24AP6Pizy38MK/zAtO12f7Ze2+fdJ/gk=</diagram></mxfile>

0 comments on commit f35ae4f

Please sign in to comment.