@we-debug/gulp-tool 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +83 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.20.0](https://github.com/dlhandsome/we-debug/compare/v0.19.0...v0.20.0) (2023-12-12)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **gulp-tool:** add plugin docs ([fed1056](https://github.com/dlhandsome/we-debug/commit/fed1056508ee5d7dae614199f03bca2b2205e0fd))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [0.19.0](https://github.com/dlhandsome/we-debug/compare/v0.18.1...v0.19.0) (2023-11-01)
|
|
7
18
|
|
|
8
19
|
|
package/README.md
CHANGED
|
@@ -48,3 +48,86 @@ filter | 页面过滤参数,可以是正则、字符串、函数或这三者
|
|
|
48
48
|
compName | we-debug 全局组件名 | `string` | `we-debug` | - |
|
|
49
49
|
compPath | we-debug 全局组件位置,可填绝对路径/相对baseDir的路径 | `string` | `@we-debug/core/component/index/index` | - |
|
|
50
50
|
entryFile | we-debug 初始化文件位置,可填绝对路径/相对baseDir的路径 | `string` | `./we-debug/index.js` | - |
|
|
51
|
+
plugins | 插件配置 | `array<{ package: string, options: object }>` | `` | - |
|
|
52
|
+
|
|
53
|
+
## 插件
|
|
54
|
+
```@we-debug/gulp-tool``` 作为 ```we-debug``` 的一个编译增强型工具,可以帮助开发者在开发调试阶段提升效率,如果开发者希望在编译阶段做更多定制化操作,比如在 wxml 插入片段,给 json 新增字段等等,就需要用到插件能力了。
|
|
55
|
+
|
|
56
|
+
想要使用一个插件,你只需要 require() 它,然后把它添加到 plugins 数组中。多数插件可以通过选项(options)自定义。
|
|
57
|
+
|
|
58
|
+
**gulpfile.js**
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
const gulp = require('gulp')
|
|
62
|
+
const weDebug = require('@we-debug/gulp-tool')
|
|
63
|
+
const wedebugGulpXXX = require('wedebug-gulp-xxx')
|
|
64
|
+
|
|
65
|
+
gulp
|
|
66
|
+
.src('dist/**/*.*')
|
|
67
|
+
.pipe(
|
|
68
|
+
weDebug({
|
|
69
|
+
baseDir: 'dist',
|
|
70
|
+
// 配置 we-debug gulp 第三方插件
|
|
71
|
+
plugins: [
|
|
72
|
+
{
|
|
73
|
+
package: wedebugGulpXXX,
|
|
74
|
+
options: { // 插件配置项,由第三方插件自由定义
|
|
75
|
+
// xxx
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
})
|
|
80
|
+
)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## 开发插件
|
|
84
|
+
|
|
85
|
+
we-debug gulp 插件需要暴露一个函数,并且在函数中进行插件注册
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
|
|
89
|
+
interface IMeta {
|
|
90
|
+
baseDir: string;
|
|
91
|
+
entryFile?: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface ITool {
|
|
95
|
+
meta: IMeta;
|
|
96
|
+
register: (options: IRegistration) => void
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
interface PluginOption {
|
|
100
|
+
[props: string]: any
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface IRegistration {
|
|
104
|
+
// 插件名称
|
|
105
|
+
pluginName: string;
|
|
106
|
+
// tool 初始化前执行
|
|
107
|
+
beforeInit?: () => void;
|
|
108
|
+
// tool 初始化时执行
|
|
109
|
+
onInit?: () => void;
|
|
110
|
+
// 检测到项目 wxml 文件后立即执行
|
|
111
|
+
wxml?: ProcessDefine;
|
|
112
|
+
// 插入 we-debug 片段之前执行
|
|
113
|
+
beforeInsertWxml?: ProcessDefine;
|
|
114
|
+
// 插入 we-debug 片段前执行
|
|
115
|
+
afterInsertWxml?: ProcessDefine;
|
|
116
|
+
// 检测到项目 json 文件后立即执行
|
|
117
|
+
json?: ProcessDefine;
|
|
118
|
+
// 检测到项目 js 文件后立即执行
|
|
119
|
+
script?: ProcessDefine;
|
|
120
|
+
// app.js 插入 we-debug import 片段前执行
|
|
121
|
+
beforeInsertScript?: ProcessDefine;
|
|
122
|
+
// app.js 插入 we-debug import 片段后执行
|
|
123
|
+
afterInsertScript?: ProcessDefine;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export default function (tool: ITool, options: PluginOption = {}): void {
|
|
127
|
+
// 注册插件
|
|
128
|
+
tool.register({
|
|
129
|
+
// ...
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@we-debug/gulp-tool",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "we-debug, gulp",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"readme": "ERROR: No README data found!",
|
|
29
29
|
"_id": "@we-debug/gulp-tool@0.1.3",
|
|
30
30
|
"_commitid": "f35f53c",
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "94f05738faa94a81e23abb4b0ea3971889abcaae"
|
|
32
32
|
}
|