@tarojs/taro 3.7.0-alpha.2 → 3.7.0-alpha.4

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.
@@ -0,0 +1,63 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ namespace requestDeviceVoIP {
5
+ interface Option {
6
+ /** 设备唯一序列号。由厂商分配,长度不能超过128字节。字符只接受数字,大小写字母,下划线(_)和连字符(-) */
7
+ sn: string
8
+ /** 设备票据,5分钟内有效 */
9
+ snTicket: string
10
+ /** 设备型号 id。通过微信公众平台注册设备获得。 */
11
+ modelId: string
12
+ /** 设备名称,将显示在授权弹窗内(长度不超过13)。授权框中「设备名字」= 「deviceName」 + 「modelId 对应设备型号」 */
13
+ deviceName: string
14
+ /** 是否为授权设备组,默认 false */
15
+ isGroup?: boolean
16
+ /** 设备组的唯一标识 id 。isGroup 为 true 时只需要传该参数,isGroup 为 false 时不需要传该参数,但需要传 sn、snTicket、modelId、deviceName 。 */
17
+ groupId: string
18
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
19
+ complete?: (res: TaroGeneral.CallbackResult) => void
20
+ /** 接口调用失败的回调函数 */
21
+ fail?: (res: TaroGeneral.CallbackResult) => void
22
+ /** 接口调用成功的回调函数 */
23
+ success?: (result: SuccessCallbackResult) => void
24
+ }
25
+ }
26
+
27
+ namespace getDeviceVoIPList {
28
+ interface Option {
29
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
30
+ complete?: (res: TaroGeneral.CallbackResult) => void
31
+ /** 接口调用失败的回调函数 */
32
+ fail?: (res: TaroGeneral.CallbackResult) => void
33
+ /** 接口调用成功的回调函数 */
34
+ success?: (result: SuccessCallbackResult) => void
35
+ }
36
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
37
+ list: DeviceVoIP[]
38
+ }
39
+ interface DeviceVoIP {
40
+ /** 设备唯一序列号。(仅单台设备时) */
41
+ sn: string
42
+ /** 设备型号 id。通过微信公众平台注册设备获得。(仅单台设备时) */
43
+ model_id: string
44
+ /** 设备组的唯一标识 id(仅设备组时) */
45
+ group_id: string
46
+ /** 设备(组)授权状态。0:未授权;1:已授权 */
47
+ status: number
48
+ }
49
+ }
50
+
51
+ interface TaroStatic {
52
+ /** 请求用户授权与设备(组)间进行音视频通话
53
+ * @supported weapp
54
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/open-api/device-voip/wx.requestDeviceVoIP.html
55
+ */
56
+ requestDeviceVoIP(option: requestDeviceVoIP.Option): Promise<TaroGeneral.CallbackResult>
57
+ /** 查询当前用户授权的音视频通话设备(组)信息
58
+ * @supported weapp
59
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/open-api/device-voip/wx.getDeviceVoIPList.html
60
+ */
61
+ getDeviceVoIPList(option: getDeviceVoIPList.Option): Promise<getDeviceVoIPList.SuccessCallbackResult>
62
+ }
63
+ }
@@ -0,0 +1,198 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ interface CacheManager {
5
+ /** 添加规则
6
+ * @supported weapp
7
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.addRule.html
8
+ */
9
+ addRule(option: CacheManager.AddRuleOption): string
10
+ /** 批量添加规则
11
+ * @supported weapp
12
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.addRules.html
13
+ */
14
+ addRules(option: CacheManager.AddRulesOption): string[]
15
+ /** 清空所有缓存
16
+ * @supported weapp
17
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.clearCaches.html
18
+ */
19
+ clearCaches(): void
20
+ /** 清空所有规则,同时会删除对应规则下所有缓存
21
+ * @supported weapp
22
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.clearRules.html
23
+ */
24
+ clearRules(): void
25
+ /** 删除缓存
26
+ * @supported weapp
27
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.deleteCache.html
28
+ */
29
+ deleteCache(
30
+ /** 缓存 id */
31
+ id: string
32
+ ): void
33
+ /** 批量删除缓存
34
+ * @supported weapp
35
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.deleteCaches.html
36
+ */
37
+ deleteCaches(
38
+ /** 缓存 id 列表 */
39
+ ids: string[]
40
+ ): void
41
+ /** 删除规则,同时会删除对应规则下所有缓存
42
+ * @supported weapp
43
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.deleteRule.html
44
+ */
45
+ deleteRule(
46
+ /** 规则 id */
47
+ id: string
48
+ ): void
49
+ /** 批量删除规则,同时会删除对应规则下所有缓存
50
+ * @supported weapp
51
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.deleteRules.html
52
+ */
53
+ deleteRules(
54
+ /** 规则 id 列表 */
55
+ ids: string[]
56
+ ): void
57
+ /** 匹配命中的缓存规则,一般需要和 request 事件搭配使用
58
+ * @supported weapp
59
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.match.html
60
+ */
61
+ match(option: CacheManager.MatchOption): CacheManager.MatchResult
62
+ /** 取消事件监听
63
+ * @supported weapp
64
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.off.html
65
+ */
66
+ off(
67
+ /** 事件名称 */
68
+ eventName: string,
69
+ /** 事件监听函数 */
70
+ handler: Function
71
+ ): void
72
+ /** 监听事件
73
+ * @supported weapp
74
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.on.html
75
+ */
76
+ on(
77
+ /** 事件名称 */
78
+ eventName: keyof CacheManager.OnEventName,
79
+ /** 事件监听函数 */
80
+ handler: Function
81
+ ): void
82
+ /** 开启缓存,仅在 mode 为 none 时生效,调用后缓存管理器的 state 会置为 1
83
+ * @supported weapp
84
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.start.html
85
+ */
86
+ start(): void
87
+ /** 关闭缓存,仅在 mode 为 none 时生效,调用后缓存管理器的 state 会置为 0
88
+ * @supported weapp
89
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.stop.html
90
+ */
91
+ stop(): void
92
+ }
93
+
94
+ namespace CacheManager {
95
+ interface DataSchema {
96
+ /** 需要匹配的 data 对象的参数类型
97
+ * string、number、boolean、null、object、any(表示任意类型),
98
+ * 同时支持数组模式(数组模式则在类型后面加 [],如 string[] 表示字符串数组)
99
+ */
100
+ type: string
101
+ /** 需要匹配的 data 对象的参数值
102
+ * 当 type 为基本类型时,可以用 string/regexp 来匹配固定的值,
103
+ * 也可以通过 function 来确定值是否匹配,
104
+ * 如果传入的 type 是 object,那么表示需要嵌套匹配值是否正确,可以传入 Array
105
+ */
106
+ value?: string | RegExp | Function | DataRule[]
107
+ }
108
+ interface DataRule {
109
+ /** 需要匹配的参数名 */
110
+ name: string
111
+ schema: DataSchema | DataSchema[]
112
+ }
113
+ interface RuleObject {
114
+ /** 规则 id,如果不填则会由基础库生成 */
115
+ id: string
116
+ /** 请求方法,可选值 GET/POST/PATCH/PUT/DELETE,如果为空则表示前面提到的所有方法都能被匹配到 */
117
+ method: string
118
+ /** uri 匹配规则,可参考规则字符串写法和正则写法 */
119
+ url: any
120
+ /**
121
+ * 缓存有效时间,单位为 ms,不填则默认取缓存管理器全局的缓存有效时间
122
+ * @default 7 * 24 * 60 * 60 * 1000
123
+ */
124
+ maxAge: number
125
+ /**
126
+ * 匹配请求参数
127
+ */
128
+ dataSchema: DataRule[]
129
+ }
130
+
131
+ type Rule = string | RegExp | RuleObject
132
+
133
+ interface AddRuleOption {
134
+ /** 规则 */
135
+ rule: Rule
136
+ }
137
+ interface AddRulesOption {
138
+ rules: Rule[]
139
+ }
140
+ interface MatchOption {
141
+ /** request 事件对象 */
142
+ evt: any
143
+ }
144
+ interface MatchResult {
145
+ /** 命中的规则id */
146
+ ruleId: string
147
+ /** 缓存id */
148
+ cacheId: string
149
+ /** 缓存内容,会带有 fromCache 标记,方便开发者区分内容是否来自缓存 */
150
+ data: any
151
+ /** 缓存创建时间 */
152
+ createTime: number
153
+ /** 缓存有效时间 */
154
+ maxAge: number
155
+ }
156
+ interface OnEventName {
157
+ /** 发生 wx.request 请求,只在缓存管理器开启阶段会触发 */
158
+ request
159
+ /** 进入弱网/离线状态 */
160
+ enterWeakNetwork
161
+ /** 离开弱网/离线状态 */
162
+ exitWeakNetwork
163
+ }
164
+ }
165
+
166
+ namespace createCacheManager {
167
+ interface Mode {
168
+ /** 弱网/离线使用缓存返回 */
169
+ weakNetwork
170
+ /** 总是使用缓存返回 */
171
+ always
172
+ /** 不开启,后续可手动开启/停止使用缓存返回 */
173
+ none
174
+ }
175
+ interface Extra {
176
+ /** 需要缓存的 wx api 接口,不传则表示支持缓存的接口全都做缓存处理。返回的如果是缓存数据,开发者可通过 fromCache 标记区分 */
177
+ apiList?: string[]
178
+ }
179
+ interface Option {
180
+ /** 全局 origin */
181
+ origin?: string
182
+ /** 缓存模式 */
183
+ mode?: keyof Mode
184
+ /** 全局缓存有效时间,单位为毫秒,默认为 7 天,最长不超过 30 天 */
185
+ maxAge?: number
186
+ /** 额外的缓存处理 */
187
+ extra?: Extra
188
+ }
189
+ }
190
+
191
+ interface TaroStatic {
192
+ /** 拉起手机发送短信界面
193
+ * @supported weap
194
+ * @see declare module '../../index'
195
+ */
196
+ createCacheManager(option: createCacheManager.Option): CacheManager
197
+ }
198
+ }
@@ -0,0 +1,200 @@
1
+ import React from 'react'
2
+
3
+ import Taro from '../index'
4
+
5
+ declare module '../index' {
6
+ namespace getAppInfo {
7
+ /** 应用信息 */
8
+ interface AppInfo {
9
+ platform: string
10
+ taroVersion: string
11
+ designWidth: number | ((size?: string | number) => number)
12
+ }
13
+ }
14
+
15
+ namespace getCurrentInstance {
16
+ interface Current {
17
+ app: AppInstance | null
18
+ router: RouterInfo | null
19
+ page: PageInstance | null
20
+ onReady: string
21
+ onHide: string
22
+ onShow: string
23
+ preloadData?: Record<any, any>
24
+ /**
25
+ * RN 私有对象navigationRef,用于使用底层接口控制路由
26
+ */
27
+ rnNavigationRef?: React.RefObject<any>
28
+ }
29
+ }
30
+
31
+ namespace setGlobalDataPlugin {
32
+ /** Vue3 插件,用于设置 `getApp()` 中的全局变量 */
33
+ interface Plugin {
34
+ install (app: any, data: any): void
35
+ }
36
+ }
37
+
38
+ /** @ignore */
39
+ interface TARO_ENV_TYPE {
40
+ [TaroGeneral.ENV_TYPE.WEAPP]: TaroGeneral.ENV_TYPE.WEAPP
41
+ [TaroGeneral.ENV_TYPE.WEB]: TaroGeneral.ENV_TYPE.WEB
42
+ [TaroGeneral.ENV_TYPE.RN]: TaroGeneral.ENV_TYPE.RN
43
+ [TaroGeneral.ENV_TYPE.SWAN]: TaroGeneral.ENV_TYPE.SWAN
44
+ [TaroGeneral.ENV_TYPE.ALIPAY]: TaroGeneral.ENV_TYPE.ALIPAY
45
+ [TaroGeneral.ENV_TYPE.TT]: TaroGeneral.ENV_TYPE.TT
46
+ [TaroGeneral.ENV_TYPE.QQ]: TaroGeneral.ENV_TYPE.QQ
47
+ [TaroGeneral.ENV_TYPE.JD]: TaroGeneral.ENV_TYPE.JD
48
+ }
49
+
50
+ namespace interceptorify {
51
+ type promiseifyApi<T, R> = (requestParams: T) => Promise<R>
52
+ interface InterceptorifyChain<T, R> {
53
+ requestParams: T
54
+ proceed: promiseifyApi<T, R>
55
+ }
56
+ type InterceptorifyInterceptor<T, R> = (chain: InterceptorifyChain<T, R>) => Promise<R>
57
+ interface Interceptorify<T, R> {
58
+ request(requestParams: T): Promise<R>
59
+ addInterceptor( interceptor: InterceptorifyInterceptor<T, R>): void
60
+ cleanInterceptors(): void
61
+ }
62
+ }
63
+
64
+ interface TaroStatic {
65
+ /** @ignore */
66
+ Events: {
67
+ new (): TaroGeneral.Events
68
+ }
69
+
70
+ /** 事件中心
71
+ * @supported global
72
+ */
73
+ eventCenter: TaroGeneral.Events
74
+
75
+ /** @ignore */
76
+ ENV_TYPE: TARO_ENV_TYPE
77
+
78
+ /** 获取环境变量
79
+ * @supported global
80
+ */
81
+ getEnv(): TaroGeneral.ENV_TYPE
82
+
83
+ /** 尺寸转换
84
+ * @supported global
85
+ */
86
+ pxTransform(size: number, designWidth?: number): string
87
+
88
+ /** 尺寸转换初始化
89
+ * @supported global
90
+ */
91
+ initPxTransform(config: {
92
+ baseFontSize?: number
93
+ deviceRatio?: TaroGeneral.TDeviceRatio
94
+ designWidth?: number | ((size?: string | number) => number)
95
+ targetUnit?: string
96
+ unitPrecision?: number
97
+ }): void
98
+
99
+ /** 小程序获取和 Taro 相关的 App 信息
100
+ * @supported weapp, alipay, jd, qq, swan, tt, h5
101
+ */
102
+ getAppInfo(): getAppInfo.AppInfo
103
+
104
+ /** 小程序引用插件 JS 接口
105
+ * @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp
106
+ */
107
+ requirePlugin(pluginName: string): any
108
+
109
+ /** 获取当前页面实例
110
+ * @supported global
111
+ */
112
+ getCurrentInstance(): getCurrentInstance.Current
113
+
114
+ /** @ignore */
115
+ Current: getCurrentInstance.Current
116
+
117
+ /** Vue3 插件,用于设置 `getApp()` 中的全局变量
118
+ * @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp
119
+ * @example
120
+ * ```js
121
+ * // 使用插件
122
+ * const App = createApp(...)
123
+ * App.use(setGlobalDataPlugin, {
124
+ * xxx: 999
125
+ * })
126
+ * // 获取全局变量
127
+ * Taro.getApp().xxx
128
+ * ```
129
+ */
130
+ setGlobalDataPlugin: setGlobalDataPlugin.Plugin
131
+
132
+ /** 获取自定义 TabBar 对应的 React 或 Vue 组件实例
133
+ * @supported weapp
134
+ * @param page 小程序页面对象,可以通过 Taro.getCurrentInstance().page 获取
135
+ */
136
+ getTabBar<T>(page: getCurrentInstance.Current['page']): T | undefined
137
+
138
+ /** 获取当前页面渲染引擎类型
139
+ * @supported weapp
140
+ */
141
+ getRenderer(): 'webview' | 'skyline'
142
+
143
+ /**
144
+ * 包裹 promiseify api 的洋葱圈模型
145
+ * @supported global
146
+ * @param promiseifyApi
147
+ * @example
148
+ * ```tsx
149
+ * // 创建实例
150
+ * const modalInterceptorify = interceptorify(taro.showModal)
151
+ * // 添加拦截器
152
+ * modalInterceptorify.addInterceptor(async function (chain) {
153
+ * const res = await chain.proceed({
154
+ * ...chain.requestParams,
155
+ * title: 'interceptor1'
156
+ * })
157
+ * return res
158
+ * })
159
+ * modalInterceptorify.addInterceptor(async function (chain) {
160
+ * const res = await chain.proceed({
161
+ * ...chain.requestParams,
162
+ * content: 'interceptor2'
163
+ * })
164
+ * return res
165
+ * })
166
+ * // 使用
167
+ * modalInterceptorify.request({})
168
+ * ```
169
+ * @example
170
+ * ```tsx
171
+ * // 创建实例
172
+ * const fetchDataInterceptorify = interceptorify(taro.request)
173
+ * // 添加拦截器
174
+ * fetchDataInterceptorify.addInterceptor(async function (chain) {
175
+ * taro.showLoading({
176
+ * title: 'Loading...'
177
+ * })
178
+ * const res = await chain.proceed(chain.requestParams)
179
+ * taro.hideLoading()
180
+ * return res
181
+ * })
182
+ * fetchDataInterceptorify.addInterceptor(async function (chain) {
183
+ * const params = chain.requestParams
184
+ * const res = await chain.proceed({
185
+ * url: 'http://httpbin.org' + params.url,
186
+ * })
187
+ * return res.data
188
+ * })
189
+ * // 使用
190
+ * fetchDataInterceptorify.request({
191
+ * url: '/ip'
192
+ * }).then((res) => {
193
+ * // log my ip
194
+ * console.log(res.origin)
195
+ * })
196
+ * ```
197
+ */
198
+ interceptorify<T, R>(promiseifyApi: interceptorify.promiseifyApi<T, R>): interceptorify.Interceptorify<T, R>
199
+ }
200
+ }
@@ -1,6 +1,6 @@
1
- import Taro from './index'
1
+ import Taro from '../index'
2
2
 
3
- declare module './index' {
3
+ declare module '../index' {
4
4
  interface TaroStatic {
5
5
  /**
6
6
  * 页面展示时的回调。
@@ -46,7 +46,7 @@ declare module './index' {
46
46
 
47
47
  /**
48
48
  * 当前是 tab 页时,tab 被点击时的回调。
49
- * @supported weapp, rn
49
+ * @supported weapp, h5, rn
50
50
  */
51
51
  useTabItemTap(callback: (payload: TabItemTapObject) => void): void
52
52
 
@@ -85,7 +85,7 @@ declare module './index' {
85
85
 
86
86
  /**
87
87
  * 小程序有未处理的 Promise reject 时触发。也可以使用 Taro.onUnhandledRejection 绑定监听。
88
- * @supported weapp, alipay
88
+ * @supported weapp, alipay, h5
89
89
  */
90
90
  useUnhandledRejection(callback: (error: { reason: Error, promise: Promise<Error> }) => void): void
91
91
 
@@ -1,4 +1,4 @@
1
- import type swc from '@swc/core'
1
+ import type { swc } from '@tarojs/helper'
2
2
  import type Webpack from 'webpack'
3
3
 
4
4
  type CompilerTypes = 'webpack4' | 'webpack5' | 'vite'
@@ -5,8 +5,11 @@ import type HtmlWebpackPlugin from 'html-webpack-plugin'
5
5
  import type { IOption, IPostcssOption } from './util'
6
6
 
7
7
  export interface IH5RouterConfig {
8
+ /** 配置路由模式 */
8
9
  mode?: 'hash' | 'browser' | 'multi'
10
+ /** 配置自定义路由 */
9
11
  customRoutes?: IOption
12
+ /** 配置路由基准路径 */
10
13
  basename?: string
11
14
  lazyload?: boolean | ((pagename: string) => boolean)
12
15
  renamePagename?: (pagename: string) => string
@@ -14,37 +17,95 @@ export interface IH5RouterConfig {
14
17
  }
15
18
 
16
19
  export interface IH5Config {
20
+ /** 设置输出解析文件的目录(默认值:'/')*/
17
21
  publicPath?: string
22
+
23
+ /** h5 编译后的静态文件目录(默认值:'static') */
18
24
  staticDirectory?: string
25
+
26
+ /** 编译后非 entry 的 js 文件的存放目录,主要影响动态引入的 pages 的存放路径(默认值:'chunk') */
19
27
  chunkDirectory?: string
20
28
 
21
29
  webpack?: ((webpackConfig: Webpack.Configuration, webpack) => Webpack.Configuration) | Webpack.Configuration
22
30
 
31
+ /**
32
+ * 自定义 Webpack 配置
33
+ * @param chain [webpackChain](https://github.com/neutrinojs/webpack-chain) 对象
34
+ * @param webpack webpack 实例
35
+ */
23
36
  webpackChain?: (chain: Chain, webpack: typeof Webpack) => void
24
37
 
38
+ /** 可用于修改、拓展 Webpack 的 output 选项,配置项参考[官方文档](https://webpack.js.org/configuration/output/) */
25
39
  output?: Webpack.Configuration['output']
40
+
41
+ /** 路由相关的配置 */
26
42
  router?: IH5RouterConfig
43
+
44
+ /** 预览服务的配置,可以更改端口等参数。具体配置参考 [webpack-dev-server](https://webpack.js.org/configuration/dev-server) */
27
45
  devServer?: webpackDevServer.Configuration
28
- sourceMapType?: 'none' | 'eval' | 'cheap-eval-source-map' | 'cheap-module-eval-source-map' | 'eval-source-map' | 'cheap-source-map' | 'cheap-module-source-map' | 'inline-cheap-source-map' | 'inline-cheap-module-source-map' | 'source-map' | 'inline-source-map' | 'hidden-source-map' | 'nosources-source-map'
46
+
47
+ /** 具体配置请参考 [Webpack devtool](https://webpack.js.org/configuration/devtool/#devtool) 配置 (默认值:'cheap-module-eval-source-map')*/
48
+ sourceMapType?:
49
+ | 'none'
50
+ | 'eval'
51
+ | 'cheap-eval-source-map'
52
+ | 'cheap-module-eval-source-map'
53
+ | 'eval-source-map'
54
+ | 'cheap-source-map'
55
+ | 'cheap-module-source-map'
56
+ | 'inline-cheap-source-map'
57
+ | 'inline-cheap-module-source-map'
58
+ | 'source-map'
59
+ | 'inline-source-map'
60
+ | 'hidden-source-map'
61
+ | 'nosources-source-map'
62
+
63
+ /** extract 功能开关,开启后将使用 mini-css-extract-plugin 分离 css 文件,可通过 h5.miniCssExtractPluginOption 对插件进行配置 (默认值:watch 模式下为 false,否则为 true) */
29
64
  enableExtract?: boolean
30
- transformOnly?: boolean
31
65
 
66
+ /** [css-loader](https://github.com/webpack-contrib/css-loader) 的附加配置 */
32
67
  cssLoaderOption?: IOption
68
+
69
+ /** [style-loader](https://github.com/webpack-contrib/style-loader) 的附加配置 */
33
70
  styleLoaderOption?: IOption
71
+
72
+ /** [sass-loader](https://github.com/webpack-contrib/sass-loader) 的附加配置 */
34
73
  sassLoaderOption?: IOption
74
+
75
+ /** [less-loader](https://github.com/webpack-contrib/less-loader) 的附加配置 */
35
76
  lessLoaderOption?: IOption
77
+
78
+ /** [stylus-loader](https://github.com/shama/stylus-loader) 的附加配置 */
36
79
  stylusLoaderOption?: IOption
80
+
81
+ /** 针对 mp4 | webm | ogg | mp3 | wav | flac | aac 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
37
82
  mediaUrlLoaderOption?: IOption
83
+
84
+ /** 针对 woff | woff2 | eot | ttf | otf 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
38
85
  fontUrlLoaderOption?: IOption
86
+
87
+ /** 针对 png | jpg | jpeg | gif | bpm | svg 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
39
88
  imageUrlLoaderOption?: IOption
89
+
90
+ /** [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) 的附加配置 */
40
91
  miniCssExtractPluginOption?: IOption
92
+
93
+ /** 配置需要额外的经由 Taro 预设的 postcss 编译的模块 */
41
94
  esnextModules?: string[]
95
+
96
+ /** 用于控制在 H5 端是否使用兼容性组件库,详情请看 [React 兼容性组件库](https://taro-docs.jd.com/docs/next/h5#react-兼容性组件库)。(默认值:false) */
42
97
  useHtmlComponents?: boolean
98
+
99
+ /** 用于控制在 H5 端是否使用旧版本适配器,旧版本采用全局注册组件,懒加载组件相关依赖;新版本适配器会自动注册相关组件,不再需要引入 @tarojs/components/loader 中的全局 defineCustomElements 方法。(默认值:false) */
43
100
  useDeprecatedAdapterComponent?: boolean
44
101
 
102
+ /** 配置 postcss 相关插件 */
45
103
  postcss?: IPostcssOption
104
+
105
+ /** html-webpack-plugin 的具体配置 */
46
106
  htmlPluginOption?: HtmlWebpackPlugin.Options
47
107
 
108
+ /** Web 编译过程的相关配置 */
48
109
  compile?: {
49
110
  exclude?: any[]
50
111
  include?: any[]
@@ -1,6 +1,6 @@
1
1
  import type Webpack from 'webpack'
2
2
  import type Chain from 'webpack-chain'
3
- import type { IMINI_APP_FILE_TYPE, IOption, IPostcssOption } from './util'
3
+ import type { IOption, IPostcssOption } from './util'
4
4
 
5
5
  interface Runtime {
6
6
  enableInnerHTML: boolean
@@ -13,36 +13,75 @@ interface Runtime {
13
13
  }
14
14
 
15
15
  export interface IMiniAppConfig {
16
- appOutput?: boolean
16
+ /** 默认值:'cheap-module-source-map', 具体参考[Webpack devtool 配置](https://webpack.js.org/configuration/devtool/#devtool) */
17
17
  sourceMapType?: string
18
+
19
+ /** 指定 React 框架相关的代码是否使用开发环境(未压缩)代码,默认使用生产环境(压缩后)代码 */
18
20
  debugReact?: boolean
21
+
22
+ /** 压缩小程序 xml 文件的相关配置 */
19
23
  minifyXML?: {
24
+ /** 是否合并 xml 文件中的空格 (默认false) */
20
25
  collapseWhitespace?: boolean
21
26
  }
22
27
 
28
+ /**
29
+ * 自定义 Webpack 配置
30
+ * @param chain [webpackChain](https://github.com/neutrinojs/webpack-chain) 对象
31
+ * @param webpack webpack 实例
32
+ * @param PARSE_AST_TYPE 小程序编译时的文件类型集合
33
+ * @returns
34
+ */
23
35
  webpackChain?: (chain: Chain, webpack: typeof Webpack, PARSE_AST_TYPE: any) => void
36
+
37
+ /** 可用于修改、拓展 Webpack 的 [output](https://webpack.js.org/configuration/output/) 选项 */
24
38
  output?: Webpack.Configuration['output']
39
+
40
+ /** 配置 postcss 相关插件 */
25
41
  postcss?: IPostcssOption
42
+
43
+ /** [css-loader](https://github.com/webpack-contrib/css-loader) 的附加配置 */
26
44
  cssLoaderOption?: IOption
45
+
46
+ /** [sass-loader](https://github.com/webpack-contrib/sass-loader) 的附加配置 */
27
47
  sassLoaderOption?: IOption
48
+
49
+ /** [less-loader](https://github.com/webpack-contrib/less-loader) 的附加配置 */
28
50
  lessLoaderOption?: IOption
51
+
52
+ /** [stylus-loader](https://github.com/shama/stylus-loader) 的附加配置 */
29
53
  stylusLoaderOption?: IOption
54
+
55
+ /** 针对 mp4 | webm | ogg | mp3 | wav | flac | aac 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
30
56
  mediaUrlLoaderOption?: IOption
57
+
58
+ /** 针对 woff | woff2 | eot | ttf | otf 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
31
59
  fontUrlLoaderOption?: IOption
60
+
61
+ /** 针对 png | jpg | jpeg | gif | bpm | svg 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
32
62
  imageUrlLoaderOption?: IOption
63
+
64
+ /** [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) 的附加配置 */
33
65
  miniCssExtractPluginOption?: IOption
34
66
 
35
- customFilesTypes?: IMINI_APP_FILE_TYPE
67
+ /** 用于告诉 Taro 编译器需要抽取的公共文件 */
36
68
  commonChunks?: string[] | ((commonChunks: string[]) => string[])
37
- addChunkPages?: ((pages: Map<string, string[]>, pagesNames?: string[]) => void)
69
+
70
+ /** 为某些页面单独指定需要引用的公共文件 */
71
+ addChunkPages?: (pages: Map<string, string[]>, pagesNames?: string[]) => void
72
+
73
+ /** 优化主包的体积大小 */
38
74
  optimizeMainPackage?: {
39
75
  enable?: boolean
40
76
  exclude?: any[]
41
77
  }
42
78
 
79
+ /** 小程序编译过程的相关配置 */
43
80
  compile?: {
44
81
  exclude?: any[]
45
82
  include?: any[]
46
83
  }
84
+
85
+ /** 插件内部使用 */
47
86
  runtime?: Runtime
48
87
  }