Skip to content

Commit

Permalink
docs: ✏️ 更新 taro 文章
Browse files Browse the repository at this point in the history
  • Loading branch information
ruochuan12 committed Dec 11, 2024
1 parent 9fe4b62 commit 87b9da6
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
- [Taro 源码揭秘 - 6. 为什么通过 Taro.xxx 能调用各个小程序平台的 API,如何设计实现的?](https://ruochuan12.github.io/taro/native-apis/)
- [Taro 源码揭秘 - 7. Taro.request 和请求响应拦截器是如何实现的?](https://ruochuan12.github.io/taro/request/)
- [Taro 源码揭秘:8. Taro 是如何使用 webpack 打包构建小程序的](https://ruochuan12.github.io/taro/webpack5-runner/)
- [Taro 源码揭秘:9. Taro 是如何生成 webpack 配置进行构建小程序的?](https://ruochuan12.github.io/taro/webpack5-runner/)


**vant 组件库源码分析系列:**
Expand Down
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
- [Taro 源码揭秘 - 5.高手都在用的发布订阅机制 Events 在 Taro 中是如何实现的?](../taro/events/)
- [Taro 源码揭秘 - 6. 为什么通过 Taro.xxx 能调用各个小程序平台的 API,如何设计实现的?](../taro/native-apis/)
- [Taro 源码揭秘 - 7. Taro.request 和请求响应拦截器是如何实现的?](../taro/request/)
- [Taro 源码揭秘:8. Taro 是如何使用 webpack 打包构建小程序的](../taro/webpack5-runner/)
- [Taro 源码揭秘:9. Taro 是如何生成 webpack 配置进行构建小程序的?](../taro/webpack5-runner/)

**vant 组件库源码分析系列:**

Expand Down
63 changes: 61 additions & 2 deletions docs/taro/mini-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ highlight: darcula
theme: smartblue
---

# Taro 源码揭秘:10.
# Taro 源码揭秘:10. taro taroMiniPlugin 插件

## 1. 前言

Expand Down Expand Up @@ -68,7 +68,66 @@ export default {

## 插件入口 apply 函数

###
```ts
export default class TaroMiniPlugin {
// 插件入口
apply (compiler: Compiler) {
this.context = compiler.context
this.appEntry = this.getAppEntry(compiler)

const {
commonChunks,
combination,
framework,
isBuildPlugin,
newBlended,
} = this.options

const {
addChunkPages,
onCompilerMake,
modifyBuildAssets,
onParseCreateElement,
} = combination.config

/** build mode */
compiler.hooks.run.tapAsync()

/** watch mode */
compiler.hooks.watchRun.tapAsync()

/** compilation.addEntry */
compiler.hooks.make.tapAsync()

compiler.hooks.compilation.tap()

compiler.hooks.afterEmit.tapAsync()

new TaroNormalModulesPlugin(onParseCreateElement).apply(compiler)

newBlended && this.addLoadChunksPlugin(compiler)
}
}
```

## compiler.hooks.run.tapAsync

```ts
/** build mode */
compiler.hooks.run.tapAsync(
PLUGIN_NAME,
this.tryAsync<Compiler>(async compiler => {
await this.run(compiler)
new TaroLoadChunksPlugin({
commonChunks: commonChunks,
isBuildPlugin,
addChunkPages,
pages: this.pages,
framework: framework
}).apply(compiler)
})
)
```

### run

Expand Down

0 comments on commit 87b9da6

Please sign in to comment.