@spcsn/taro 0.1.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/README.md +12 -0
- package/dist/index.js +147 -0
- package/dist/index.js.map +1 -0
- package/index.js +9 -0
- package/package.json +86 -0
- package/types/api/ad/index.d.ts +197 -0
- package/types/api/ai/face.d.ts +133 -0
- package/types/api/ai/inference.d.ts +129 -0
- package/types/api/ai/visionkit.d.ts +874 -0
- package/types/api/alipay/index.d.ts +69 -0
- package/types/api/base/crypto.d.ts +104 -0
- package/types/api/base/debug.d.ts +329 -0
- package/types/api/base/env.d.ts +19 -0
- package/types/api/base/index.d.ts +102 -0
- package/types/api/base/performance.d.ts +258 -0
- package/types/api/base/system.d.ts +742 -0
- package/types/api/base/update.d.ts +130 -0
- package/types/api/base/weapp/app-event.d.ts +265 -0
- package/types/api/base/weapp/life-cycle.d.ts +155 -0
- package/types/api/canvas/index.d.ts +2162 -0
- package/types/api/cloud/index.d.ts +2622 -0
- package/types/api/data-analysis/index.d.ts +122 -0
- package/types/api/device/accelerometer.d.ts +102 -0
- package/types/api/device/accessibility.d.ts +26 -0
- package/types/api/device/battery.d.ts +46 -0
- package/types/api/device/bluetooth-ble.d.ts +601 -0
- package/types/api/device/bluetooth-peripheral.d.ts +430 -0
- package/types/api/device/bluetooth.d.ts +463 -0
- package/types/api/device/calendar.d.ts +98 -0
- package/types/api/device/clipboard.d.ts +81 -0
- package/types/api/device/compass.d.ts +105 -0
- package/types/api/device/contact.d.ts +110 -0
- package/types/api/device/gyroscope.d.ts +85 -0
- package/types/api/device/iBeacon.d.ts +168 -0
- package/types/api/device/keyboard.d.ts +97 -0
- package/types/api/device/memory.d.ts +52 -0
- package/types/api/device/motion.d.ts +88 -0
- package/types/api/device/network.d.ts +172 -0
- package/types/api/device/nfc.d.ts +1238 -0
- package/types/api/device/phone.d.ts +30 -0
- package/types/api/device/scan.d.ts +111 -0
- package/types/api/device/screen.d.ts +217 -0
- package/types/api/device/sms.d.ts +26 -0
- package/types/api/device/vibrate.d.ts +51 -0
- package/types/api/device/wifi.d.ts +301 -0
- package/types/api/ext/index.d.ts +64 -0
- package/types/api/files/index.d.ts +1472 -0
- package/types/api/framework/index.d.ts +51 -0
- package/types/api/location/index.d.ts +517 -0
- package/types/api/media/audio.d.ts +1013 -0
- package/types/api/media/background-audio.d.ts +291 -0
- package/types/api/media/camera.d.ts +207 -0
- package/types/api/media/editor.d.ts +239 -0
- package/types/api/media/image.d.ts +469 -0
- package/types/api/media/live.d.ts +461 -0
- package/types/api/media/map.d.ts +638 -0
- package/types/api/media/media-recorder.d.ts +117 -0
- package/types/api/media/recorder.d.ts +317 -0
- package/types/api/media/video-decoder.d.ts +117 -0
- package/types/api/media/video-processing.d.ts +84 -0
- package/types/api/media/video.d.ts +527 -0
- package/types/api/media/voip.d.ts +393 -0
- package/types/api/navigate/index.d.ts +327 -0
- package/types/api/network/download.d.ts +173 -0
- package/types/api/network/mdns.d.ts +191 -0
- package/types/api/network/request.d.ts +480 -0
- package/types/api/network/tcp.d.ts +181 -0
- package/types/api/network/udp.d.ts +218 -0
- package/types/api/network/upload.d.ts +201 -0
- package/types/api/network/websocket.d.ts +383 -0
- package/types/api/open-api/account.d.ts +51 -0
- package/types/api/open-api/address.d.ts +68 -0
- package/types/api/open-api/authorize.d.ts +80 -0
- package/types/api/open-api/card.d.ts +110 -0
- package/types/api/open-api/channels.d.ts +225 -0
- package/types/api/open-api/customer-service.d.ts +45 -0
- package/types/api/open-api/device-voip.d.ts +103 -0
- package/types/api/open-api/facial.d.ts +98 -0
- package/types/api/open-api/favorites.d.ts +101 -0
- package/types/api/open-api/group.d.ts +59 -0
- package/types/api/open-api/invoice.d.ts +87 -0
- package/types/api/open-api/license-plate.d.ts +27 -0
- package/types/api/open-api/login.d.ts +115 -0
- package/types/api/open-api/my-miniprogram.d.ts +28 -0
- package/types/api/open-api/privacy.d.ts +107 -0
- package/types/api/open-api/redpackage.d.ts +24 -0
- package/types/api/open-api/settings.d.ts +174 -0
- package/types/api/open-api/soter.d.ts +184 -0
- package/types/api/open-api/sticker.d.ts +83 -0
- package/types/api/open-api/subscribe-message.d.ts +305 -0
- package/types/api/open-api/user-info.d.ts +182 -0
- package/types/api/open-api/werun.d.ts +101 -0
- package/types/api/payment/index.d.ts +119 -0
- package/types/api/qq/index.d.ts +354 -0
- package/types/api/route/index.d.ts +324 -0
- package/types/api/share/index.d.ts +354 -0
- package/types/api/skyline/index.d.ts +345 -0
- package/types/api/storage/background-fetch.d.ts +131 -0
- package/types/api/storage/cache-manager.d.ts +249 -0
- package/types/api/storage/index.d.ts +405 -0
- package/types/api/swan/bookshelf.d.ts +307 -0
- package/types/api/swan/download-package.d.ts +80 -0
- package/types/api/swan/index.d.ts +251 -0
- package/types/api/swan/pay.d.ts +139 -0
- package/types/api/taro.extend.d.ts +233 -0
- package/types/api/taro.hooks.d.ts +148 -0
- package/types/api/ui/animation.d.ts +427 -0
- package/types/api/ui/background.d.ts +69 -0
- package/types/api/ui/custom-component.d.ts +23 -0
- package/types/api/ui/fonts.d.ts +77 -0
- package/types/api/ui/interaction.d.ts +281 -0
- package/types/api/ui/menu.d.ts +29 -0
- package/types/api/ui/navigation-bar.d.ts +130 -0
- package/types/api/ui/pull-down-refresh.d.ts +50 -0
- package/types/api/ui/scroll.d.ts +114 -0
- package/types/api/ui/sticky.d.ts +32 -0
- package/types/api/ui/tab-bar.d.ts +196 -0
- package/types/api/ui/window.d.ts +71 -0
- package/types/api/worker/index.d.ts +83 -0
- package/types/api/wxml/index.d.ts +540 -0
- package/types/compile/compiler.d.ts +32 -0
- package/types/compile/config/h5.d.ts +134 -0
- package/types/compile/config/harmony.d.ts +118 -0
- package/types/compile/config/index.d.ts +8 -0
- package/types/compile/config/manifest.d.ts +155 -0
- package/types/compile/config/mini.d.ts +118 -0
- package/types/compile/config/plugin.d.ts +34 -0
- package/types/compile/config/project.d.ts +338 -0
- package/types/compile/config/rn.d.ts +85 -0
- package/types/compile/config/util.d.ts +179 -0
- package/types/compile/hooks.d.ts +13 -0
- package/types/compile/index.d.ts +11 -0
- package/types/compile/viteCompilerContext.d.ts +167 -0
- package/types/global.d.ts +428 -0
- package/types/index.d.ts +190 -0
- package/types/taro.api.d.ts +130 -0
- package/types/taro.component.d.ts +168 -0
- package/types/taro.config.d.ts +712 -0
- package/types/taro.lifecycle.d.ts +220 -0
- package/types/taro.runtime.d.ts +9 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import type Webpack from 'webpack'
|
|
2
|
+
import type Chain from 'webpack-chain'
|
|
3
|
+
import type { Input } from 'postcss'
|
|
4
|
+
import type { AppConfig } from '../../index'
|
|
5
|
+
import type { Compiler, CompilerTypes, CompilerWebpackTypes } from '../compiler'
|
|
6
|
+
import type { IModifyChainData } from '../hooks'
|
|
7
|
+
import type { ICopyOptions, IOption, ISassOptions, TogglableOptions } from './util'
|
|
8
|
+
import type { IH5Config } from './h5'
|
|
9
|
+
import type { IHarmonyConfig } from './harmony'
|
|
10
|
+
import type { IMiniAppConfig, IMiniFilesConfig } from './mini'
|
|
11
|
+
import type { IRNConfig } from './rn'
|
|
12
|
+
|
|
13
|
+
export type PluginItem<T = object> = string | [string, T] | [string, () => T | Promise<T>]
|
|
14
|
+
|
|
15
|
+
interface ICache {
|
|
16
|
+
/**
|
|
17
|
+
* 是否开启持久化缓存 (默认值 false)
|
|
18
|
+
* @description ```
|
|
19
|
+
* 值为 false 时:开发模式下 WebpackConfig.cache.type = 'memory',而生产模式下 WebpackConfig.cache = false;
|
|
20
|
+
* 值为 true 时:开发模式和生产模式下均为 WebpackConfig.cache.type = 'filesystem'
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
enable?: boolean
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 当依赖的文件或该文件的依赖改变时,使缓存失效。
|
|
27
|
+
* @description 详详情请参考 [WebpackConfig.cache.buildDependencies](https://webpack.js.org/configuration/cache/#cachebuilddependencies)。
|
|
28
|
+
*/
|
|
29
|
+
buildDependencies?: Record<string, any>
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 缓存子目录的名称 (默认值 process.env.NODE_ENV-process.env.TARO_ENV)
|
|
33
|
+
* @description 详情请参考 [WebpackConfig.cache.name](https://webpack.js.org/configuration/cache/#cachename)
|
|
34
|
+
*/
|
|
35
|
+
name?: string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface ILogger {
|
|
39
|
+
/** 是否简化输出日志 (默认值 true)*/
|
|
40
|
+
quiet: boolean
|
|
41
|
+
/** 是否输出 Webpack Stats 信息 (默认值 false) */
|
|
42
|
+
stats: boolean
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface IProjectBaseConfig {
|
|
46
|
+
isWatch?: boolean
|
|
47
|
+
port?: number
|
|
48
|
+
/** 项目名称 */
|
|
49
|
+
projectName?: string
|
|
50
|
+
|
|
51
|
+
/** 项目创建日期 */
|
|
52
|
+
date?: string
|
|
53
|
+
|
|
54
|
+
/** 设计稿尺寸 */
|
|
55
|
+
designWidth?: number | ((size?: string | number | Input) => number)
|
|
56
|
+
|
|
57
|
+
/** 设计稿尺寸换算规则 */
|
|
58
|
+
deviceRatio?: TaroGeneral.TDeviceRatio
|
|
59
|
+
|
|
60
|
+
watcher?: any[]
|
|
61
|
+
|
|
62
|
+
/** 源码存放目录 (默认值:'src') */
|
|
63
|
+
sourceRoot?: string
|
|
64
|
+
|
|
65
|
+
/** 代码编译后的生产目录 (默认值:'dist') */
|
|
66
|
+
outputRoot?: string
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 用于配置`process.env.xxxx`相关的环境变量
|
|
70
|
+
* @deprecated 建议使用根目录下的 .env 文件替代
|
|
71
|
+
* @description 注意:这里的环境变量只能在业务代码中使用,编译时的 node 环境中无法使用
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* // config/index.ts
|
|
75
|
+
* export default defineConfig({
|
|
76
|
+
* env: {
|
|
77
|
+
* xxxx: '"测试"'
|
|
78
|
+
* }
|
|
79
|
+
* })
|
|
80
|
+
*
|
|
81
|
+
* // src/app.ts
|
|
82
|
+
* onShow() {
|
|
83
|
+
* console.log(process.env.xxxx) // 打印 "测试"
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
env?: IOption
|
|
88
|
+
|
|
89
|
+
/** 用于配置目录别名,从而方便书写代码引用路径 */
|
|
90
|
+
alias?: IOption
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 用于配置一些常量供代码中进行全局替换使用
|
|
94
|
+
* @description 注意:这里的环境变量只能在业务代码中使用,编译时的 node 环境中无法使用
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* // config/index.ts
|
|
98
|
+
* export default defineConfig({
|
|
99
|
+
* defineConstants: {
|
|
100
|
+
* __TEST__: JSON.stringify('test')
|
|
101
|
+
* }
|
|
102
|
+
* })
|
|
103
|
+
*
|
|
104
|
+
* // src/app.ts
|
|
105
|
+
* onShow() {
|
|
106
|
+
* console.log(__TEST__) // 打印 "test"
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
defineConstants?: IOption
|
|
111
|
+
|
|
112
|
+
/** 用于把文件从源码目录直接拷贝到编译后的生产目录 */
|
|
113
|
+
copy?: ICopyOptions
|
|
114
|
+
|
|
115
|
+
/** 配置 JS 压缩工具 (默认 terser) */
|
|
116
|
+
jsMinimizer?: 'terser' | 'esbuild'
|
|
117
|
+
|
|
118
|
+
/** 配置 CSS 压缩工具 (默认 csso) */
|
|
119
|
+
cssMinimizer?: 'csso' | 'esbuild' | 'lightningcss'
|
|
120
|
+
|
|
121
|
+
/** 配置 csso 工具以压缩 CSS 代码 */
|
|
122
|
+
csso?: TogglableOptions
|
|
123
|
+
|
|
124
|
+
/** 配置 terser 工具以压缩 JS 代码 */
|
|
125
|
+
terser?: TogglableOptions
|
|
126
|
+
|
|
127
|
+
esbuild?: Record<'minify', TogglableOptions>
|
|
128
|
+
|
|
129
|
+
uglify?: TogglableOptions
|
|
130
|
+
|
|
131
|
+
/** 用于控制对 scss 代码的编译行为,默认使用 dart-sass,具体配置可以参考 https://www.npmjs.com/package/sass */
|
|
132
|
+
sass?: ISassOptions
|
|
133
|
+
|
|
134
|
+
/** 配置 Taro 插件 */
|
|
135
|
+
plugins?: PluginItem[]
|
|
136
|
+
|
|
137
|
+
/** 一个 preset 是一系列 Taro 插件的集合,配置语法同 plugins */
|
|
138
|
+
presets?: PluginItem[]
|
|
139
|
+
|
|
140
|
+
/** 模板循环次数 */
|
|
141
|
+
baseLevel?: number
|
|
142
|
+
|
|
143
|
+
/** 使用的开发框架。可选值:react、preact、vue3 */
|
|
144
|
+
framework?: 'react' | 'preact' | 'solid' | 'vue3'
|
|
145
|
+
frameworkExts?: string[]
|
|
146
|
+
|
|
147
|
+
/** 使用的编译工具。可选值:webpack5 */
|
|
148
|
+
compiler?: Compiler
|
|
149
|
+
|
|
150
|
+
/** Webpack5 持久化缓存配置。具体配置请参考 [WebpackConfig.cache](https://webpack.js.org/configuration/cache/#cache) */
|
|
151
|
+
cache?: ICache
|
|
152
|
+
|
|
153
|
+
/** 控制 Taro 编译日志的输出方式 */
|
|
154
|
+
logger?: ILogger
|
|
155
|
+
|
|
156
|
+
/** 用于控制是否生成 js、css 对应的 sourceMap */
|
|
157
|
+
enableSourceMap?: boolean
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 编译开始
|
|
161
|
+
*/
|
|
162
|
+
onBuildStart?: (...args: any[]) => Promise<any>
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* 编译完成(启动项目后首次编译结束后会触发一次)
|
|
166
|
+
*/
|
|
167
|
+
onBuildComplete?: (...args: any[]) => Promise<any>
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 编译结束(保存代码每次编译结束后都会触发)
|
|
171
|
+
*/
|
|
172
|
+
onBuildFinish?: (res: { error; stats; isWatch }) => Promise<any>
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 修改编译过程中的页面组件配置
|
|
176
|
+
*/
|
|
177
|
+
onCompilerMake?: (compilation: Webpack.Compilation, compiler: Webpack.Compiler, plugin: any) => Promise<any>
|
|
178
|
+
|
|
179
|
+
onWebpackChainReady?: (webpackChain: Chain) => Promise<any>
|
|
180
|
+
|
|
181
|
+
modifyAppConfig?: (appConfig: AppConfig) => Promise<any>
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* 编译中修改 webpack 配置,在这个钩子中,你可以对 webpackChain 作出想要的调整,等同于配置 [`webpackChain`](./config-detail#miniwebpackchain)
|
|
185
|
+
*/
|
|
186
|
+
modifyWebpackChain?: (chain: Chain, webpack: typeof Webpack, data: IModifyChainData) => Promise<any>
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 编译中修改 vite 配置
|
|
190
|
+
*/
|
|
191
|
+
modifyViteConfig?: (viteConfig: any, data: IModifyChainData) => void
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* 修改编译后的结果
|
|
195
|
+
*/
|
|
196
|
+
modifyBuildAssets?: (assets: any, miniPlugin?: any) => Promise<any>
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* 修改编译过程中的页面组件配置
|
|
200
|
+
*/
|
|
201
|
+
modifyMiniConfigs?: (configMap: IMiniFilesConfig) => Promise<any>
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* 修改 Taro 编译配置
|
|
205
|
+
*/
|
|
206
|
+
modifyRunnerOpts?: (opts: any) => Promise<any>
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** 暴露出来给 config/index 使用的配置类型,参考 https://github.com/NervJS/taro-doctor/blob/main/assets/config_schema.json */
|
|
210
|
+
export interface IProjectConfig<T extends CompilerTypes = CompilerWebpackTypes> {
|
|
211
|
+
/** 项目名称 */
|
|
212
|
+
projectName?: string
|
|
213
|
+
|
|
214
|
+
/** 项目创建日期 */
|
|
215
|
+
date?: string
|
|
216
|
+
|
|
217
|
+
/** 设计稿尺寸 */
|
|
218
|
+
designWidth?: number | ((size?: string | number | Input) => number)
|
|
219
|
+
|
|
220
|
+
/** 设计稿尺寸换算规则 */
|
|
221
|
+
deviceRatio?: TaroGeneral.TDeviceRatio
|
|
222
|
+
|
|
223
|
+
/** 源码存放目录 (默认值:'src') */
|
|
224
|
+
sourceRoot?: string
|
|
225
|
+
|
|
226
|
+
/** 代码编译后的生产目录 (默认值:'dist') */
|
|
227
|
+
outputRoot?: string
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* 用于配置`process.env.xxxx`相关的环境变量
|
|
231
|
+
* @deprecated 建议使用根目录下的 .env 文件替代
|
|
232
|
+
* @description 注意:这里的环境变量只能在业务代码中使用,编译时的 node 环境中无法使用
|
|
233
|
+
* @example
|
|
234
|
+
* ```ts
|
|
235
|
+
* // config/index.ts
|
|
236
|
+
* export default defineConfig({
|
|
237
|
+
* env: {
|
|
238
|
+
* xxxx: '"测试"'
|
|
239
|
+
* }
|
|
240
|
+
* })
|
|
241
|
+
*
|
|
242
|
+
* // src/app.ts
|
|
243
|
+
* onShow() {
|
|
244
|
+
* console.log(process.env.xxxx) // 打印 "测试"
|
|
245
|
+
* }
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
env?: IOption
|
|
249
|
+
|
|
250
|
+
/** 用于配置目录别名,从而方便书写代码引用路径 */
|
|
251
|
+
alias?: IOption
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* 用于配置一些常量供代码中进行全局替换使用
|
|
255
|
+
* @description 注意:这里的环境变量只能在业务代码中使用,编译时的 node 环境中无法使用
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* // config/index.ts
|
|
259
|
+
* export default defineConfig({
|
|
260
|
+
* defineConstants: {
|
|
261
|
+
* __TEST__: JSON.stringify('test')
|
|
262
|
+
* }
|
|
263
|
+
* })
|
|
264
|
+
*
|
|
265
|
+
* // src/app.ts
|
|
266
|
+
* onShow() {
|
|
267
|
+
* console.log(__TEST__) // 打印 "test"
|
|
268
|
+
* }
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
defineConstants?: IOption
|
|
272
|
+
|
|
273
|
+
/** 用于把文件从源码目录直接拷贝到编译后的生产目录 */
|
|
274
|
+
copy?: ICopyOptions
|
|
275
|
+
|
|
276
|
+
/** 配置 JS 压缩工具 (默认 terser) */
|
|
277
|
+
jsMinimizer?: 'terser' | 'esbuild'
|
|
278
|
+
|
|
279
|
+
/** 配置 CSS 压缩工具 (默认 csso) */
|
|
280
|
+
cssMinimizer?: 'csso' | 'esbuild' | 'lightningcss'
|
|
281
|
+
|
|
282
|
+
/** 配置 csso 工具以压缩 CSS 代码 */
|
|
283
|
+
csso?: TogglableOptions
|
|
284
|
+
|
|
285
|
+
/** 配置 terser 工具以压缩 JS 代码 */
|
|
286
|
+
terser?: TogglableOptions
|
|
287
|
+
|
|
288
|
+
esbuild?: Record<'minify', TogglableOptions>
|
|
289
|
+
|
|
290
|
+
/** 用于控制对 scss 代码的编译行为,默认使用 dart-sass,具体配置可以参考 https://www.npmjs.com/package/sass */
|
|
291
|
+
sass?: ISassOptions
|
|
292
|
+
|
|
293
|
+
/** 配置 Taro 插件 */
|
|
294
|
+
plugins?: PluginItem[]
|
|
295
|
+
|
|
296
|
+
/** 一个 preset 是一系列 Taro 插件的集合,配置语法同 plugins */
|
|
297
|
+
presets?: PluginItem[]
|
|
298
|
+
|
|
299
|
+
/** 使用的开发框架。可选值:react、preact、solid、vue3、 none */
|
|
300
|
+
framework?: 'react' | 'preact' | 'solid' | 'vue3' | 'none'
|
|
301
|
+
|
|
302
|
+
/** Webpack5 持久化缓存配置。具体配置请参考 [WebpackConfig.cache](https://webpack.js.org/configuration/cache/#cache) */
|
|
303
|
+
cache?: ICache
|
|
304
|
+
|
|
305
|
+
/** 控制 Taro 编译日志的输出方式 */
|
|
306
|
+
logger?: ILogger
|
|
307
|
+
|
|
308
|
+
/** 使用的编译工具。可选值:webpack5、vite */
|
|
309
|
+
compiler?: Compiler<T>
|
|
310
|
+
|
|
311
|
+
/** 专属于 H5 的配置 */
|
|
312
|
+
h5?: IH5Config<T>
|
|
313
|
+
|
|
314
|
+
/** 专属于小程序的配置 */
|
|
315
|
+
mini?: IMiniAppConfig<T>
|
|
316
|
+
|
|
317
|
+
/** 专属于 RN 的配置 */
|
|
318
|
+
rn?: IRNConfig
|
|
319
|
+
|
|
320
|
+
harmony?: IHarmonyConfig<T>
|
|
321
|
+
|
|
322
|
+
[key: string]: any
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export interface OutputExt {
|
|
326
|
+
/**
|
|
327
|
+
* 编译前清空输出目录
|
|
328
|
+
* @since Taro v3.6.9
|
|
329
|
+
* @description
|
|
330
|
+
* - 默认清空输出目录,可设置 clean: false 不清空
|
|
331
|
+
* - 可设置 clean: { keep: ['project.config.json'] } 保留指定文件
|
|
332
|
+
* - 注意 clean.keep 不支持函数
|
|
333
|
+
*/
|
|
334
|
+
clean?: boolean | {
|
|
335
|
+
/** 保留指定文件不删除 */
|
|
336
|
+
keep?: Array<string | RegExp> | string | RegExp
|
|
337
|
+
}
|
|
338
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type Webpack from 'webpack'
|
|
2
|
+
import type Chain from 'webpack-chain'
|
|
3
|
+
import type webpackDevServer from 'webpack-dev-server'
|
|
4
|
+
import type HtmlWebpackPlugin from 'html-webpack-plugin'
|
|
5
|
+
import type { RollupOptions } from 'rollup'
|
|
6
|
+
import type { IOption, IPostcssOption } from './util'
|
|
7
|
+
|
|
8
|
+
export interface IRNConfig {
|
|
9
|
+
/** 设置 RN bundle 中注册应用的名称 */
|
|
10
|
+
appName?: string
|
|
11
|
+
|
|
12
|
+
/** entry 利用模块查找规则{name}.{platform}.{ext}自动区分平台 */
|
|
13
|
+
entry?: string
|
|
14
|
+
|
|
15
|
+
/** 设置 Metro 打包生成 bundle 的输出路径,默认 dist 目录下 */
|
|
16
|
+
output?: any
|
|
17
|
+
|
|
18
|
+
/** [sass](https://github.com/sass/node-sass#options) 相关配置 */
|
|
19
|
+
sass?: IOption
|
|
20
|
+
|
|
21
|
+
/** [less](https://lesscss.org/usage/#less-options) 相关配置 */
|
|
22
|
+
less?: IOption
|
|
23
|
+
|
|
24
|
+
/** [stylus](https://github.com/NervJS/taro/blob/main/packages/taro-rn-style-transformer/README.md#rnstylus) 相关配置 */
|
|
25
|
+
stylus?: IOption
|
|
26
|
+
|
|
27
|
+
/** 配置 postcss 相关插件 */
|
|
28
|
+
postcss?: {
|
|
29
|
+
/** postcss 配置,参考 https://github.com/postcss/postcss#options */
|
|
30
|
+
options?: any
|
|
31
|
+
/** 默认true,控制是否对 css value 进行 scalePx2dp 转换,pxtransform配置 enable 才生效 */
|
|
32
|
+
scalable?: boolean
|
|
33
|
+
pxtransform?: {
|
|
34
|
+
enable?: boolean
|
|
35
|
+
/** 插件 pxtransform 配置项 */
|
|
36
|
+
config?: {
|
|
37
|
+
additionalProperties?: boolean
|
|
38
|
+
[key: string]: any
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
cssModules?: {
|
|
42
|
+
enable: boolean
|
|
43
|
+
},
|
|
44
|
+
[key: string]: any
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
resolve?: any
|
|
48
|
+
|
|
49
|
+
/** 支持多 className 转换,以 classname 或 style 结尾的, 提取前缀, 然后根据前缀,再生成对应的 xxxStyle。如:barClassName -> barStyle。默认值 false,不开启 */
|
|
50
|
+
enableMultipleClassName?: boolean
|
|
51
|
+
|
|
52
|
+
/** 当标签 style 属性值是数组时转换成对象。默认值 false,不开启 */
|
|
53
|
+
enableMergeStyle?: boolean
|
|
54
|
+
|
|
55
|
+
/** 将 svg 文件转换为组件引入。默认值 false,不开启 */
|
|
56
|
+
enableSvgTransform?: boolean
|
|
57
|
+
|
|
58
|
+
alias?: IOption
|
|
59
|
+
|
|
60
|
+
/** 设计稿尺寸 */
|
|
61
|
+
designWidth?: number | ((size?: string | number | Input) => number)
|
|
62
|
+
|
|
63
|
+
/** 设计稿尺寸换算规则 */
|
|
64
|
+
deviceRatio?: TaroGeneral.TDeviceRatio
|
|
65
|
+
|
|
66
|
+
/** 原生组件编译配置 */
|
|
67
|
+
nativeComponents?: {
|
|
68
|
+
/**
|
|
69
|
+
* 外部依赖
|
|
70
|
+
*/
|
|
71
|
+
external?: Array<string | RegExp> | ((arr: Array<string | RegExp>) => Array<string | RegExp>)
|
|
72
|
+
/**
|
|
73
|
+
* 设置外部依赖,如果返回 string, 则将该值作为 external, 我们默认将 node_modules 路径下的文件设置为外部依赖
|
|
74
|
+
*/
|
|
75
|
+
exteranlResolve?: (importee: string, importer: string) => string
|
|
76
|
+
/**
|
|
77
|
+
* 组件输出路径,默认值为 'dist'
|
|
78
|
+
*/
|
|
79
|
+
output?: string
|
|
80
|
+
/**
|
|
81
|
+
* 修改 Rollup 打包配置
|
|
82
|
+
*/
|
|
83
|
+
modifyRollupConfig?: (config: RollupOptions, innerPlugins: { taroResolver: typeof taroResolver, styleTransformer: typeof styleTransformer }) => RollupOptions
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import type { Input } from 'postcss'
|
|
2
|
+
import type { Options as PostcssUrlOption } from 'postcss-url'
|
|
3
|
+
|
|
4
|
+
export type Func = (...args: any[]) => any
|
|
5
|
+
|
|
6
|
+
export type IOption = Record<string, any>
|
|
7
|
+
|
|
8
|
+
export type TogglableOptions<T = IOption> = {
|
|
9
|
+
enable?: boolean
|
|
10
|
+
config?: T
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface IUrlLoaderOption extends IOption {
|
|
14
|
+
limit?: number | boolean
|
|
15
|
+
name?: ((moduleId: string) => string) | string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export namespace PostcssOption {
|
|
19
|
+
export type cssModules = TogglableOptions<{
|
|
20
|
+
/** 转换模式,取值为 global/module */
|
|
21
|
+
namingPattern: 'global' | string
|
|
22
|
+
/** 自定义生成的class名称规则 */
|
|
23
|
+
generateScopedName: string | ((localName: string, absoluteFilePath: string) => string)
|
|
24
|
+
}>
|
|
25
|
+
export type url = TogglableOptions<PostcssUrlOption>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface IHtmlTransformOption {
|
|
29
|
+
/** 是否启用 postcss-html-transform 插件 */
|
|
30
|
+
enable?: boolean
|
|
31
|
+
config?: {
|
|
32
|
+
/** 当前编译平台 (此选项插件内部根据编译平台自行生成,无需传入) */
|
|
33
|
+
readonly platform?: string
|
|
34
|
+
/** 设置是否去除 cursor 相关样式 (h5默认值:true) */
|
|
35
|
+
removeCursorStyle: boolean
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface IPxTransformOption {
|
|
40
|
+
/** 设置 1px 是否需要被转换 */
|
|
41
|
+
onePxTransform?: boolean
|
|
42
|
+
/** REM 单位允许的小数位 */
|
|
43
|
+
unitPrecision?: number
|
|
44
|
+
/** 允许转换的属性列表 (默认 [*]) */
|
|
45
|
+
propList?: string[]
|
|
46
|
+
/** 黑名单里的选择器将会被忽略 */
|
|
47
|
+
selectorBlackList?: Array<string | RegExp>
|
|
48
|
+
/** 直接替换而不是追加一条进行覆盖 */
|
|
49
|
+
replace?: boolean
|
|
50
|
+
/** 允许媒体查询里的 px 单位转换 */
|
|
51
|
+
mediaQuery?: boolean
|
|
52
|
+
/** 设置一个可被转换的最小 px 值 */
|
|
53
|
+
minPixelValue?: number
|
|
54
|
+
/**
|
|
55
|
+
* 转换后的单位,可选值为 rpx、vw、rem,当前仅支持小程序 (默认 rpx) 和 Web 端 (默认 rem)
|
|
56
|
+
* @description Web 端使用 rem 单位时会注入脚本用于设置 body 上的 font-size 属性,其他单位无该操作
|
|
57
|
+
*/
|
|
58
|
+
targetUnit?: 'rpx' | 'vw' | 'rem'
|
|
59
|
+
/**
|
|
60
|
+
* H5 字体尺寸大小基准值,开发者可以自行调整单位换算的基准值(默认20)
|
|
61
|
+
* @supported h5
|
|
62
|
+
*/
|
|
63
|
+
baseFontSize?: number
|
|
64
|
+
/**
|
|
65
|
+
* H5 根节点 font-size 的最大值 (默认 40)
|
|
66
|
+
* @supported h5
|
|
67
|
+
*/
|
|
68
|
+
maxRootSize?: number
|
|
69
|
+
/**
|
|
70
|
+
* H5 根节点 font-size 的最小值(默认 20)
|
|
71
|
+
* @supported h5
|
|
72
|
+
*/
|
|
73
|
+
minRootSize?: number
|
|
74
|
+
/** 设计稿尺寸 */
|
|
75
|
+
designWidth?: number | ((size?: string | number | Input) => number)
|
|
76
|
+
/** 设计稿尺寸换算规则 */
|
|
77
|
+
deviceRatio?: TaroGeneral.TDeviceRatio
|
|
78
|
+
/** 平台 */
|
|
79
|
+
platform?: 'weapp' | 'h5' | string
|
|
80
|
+
/** 启用的能力 Scope 默认为 ['platform', 'size'] */
|
|
81
|
+
methods?: string[]
|
|
82
|
+
/** filter 回调函数,可 exclude 不处理的文件 */
|
|
83
|
+
exclude?: (fileName: string) => boolean
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface IBasePostcssOption {
|
|
87
|
+
autoprefixer?: TogglableOptions
|
|
88
|
+
pxtransform?: TogglableOptions<IPxTransformOption>
|
|
89
|
+
cssModules?: PostcssOption.cssModules
|
|
90
|
+
/** 插件 postcss-html-transform 相关配置, 一般启用了 @tarojs/plugin-html 插件才配置 */
|
|
91
|
+
htmltransform?: IHtmlTransformOption
|
|
92
|
+
[key: string]: any
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export type IPostcssOption<T = 'h5' | 'harmony' | 'mini'> = T extends 'h5'
|
|
96
|
+
? IBasePostcssOption & { url?: PostcssOption.url }
|
|
97
|
+
: IBasePostcssOption
|
|
98
|
+
|
|
99
|
+
export type Config = ViteConfig | WebpackConfig
|
|
100
|
+
|
|
101
|
+
export interface ICopyOptions {
|
|
102
|
+
patterns: {
|
|
103
|
+
from: string
|
|
104
|
+
to: string
|
|
105
|
+
ignore?: string[]
|
|
106
|
+
transform?: Func
|
|
107
|
+
watch?: boolean
|
|
108
|
+
}[]
|
|
109
|
+
options: {
|
|
110
|
+
ignore?: string[]
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface ISassOptions {
|
|
115
|
+
/**
|
|
116
|
+
* 引入的全局 sass 文件,如果要引入多个文件,支持数组形式传入
|
|
117
|
+
*/
|
|
118
|
+
resource?: string | string[]
|
|
119
|
+
/**
|
|
120
|
+
* 项目根目录的绝对地址(若为小程序云开发模板,则应该是client目录)
|
|
121
|
+
*/
|
|
122
|
+
projectDirectory?: string
|
|
123
|
+
/**
|
|
124
|
+
* 全局 scss 变量,若 data 与 resource 中设置了同样的变量,则 data 的优先级高于 resource
|
|
125
|
+
*/
|
|
126
|
+
data?: string
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface ICompileOption {
|
|
130
|
+
exclude?: string[]
|
|
131
|
+
include?: string[]
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export const enum TEMPLATE_TYPES {
|
|
135
|
+
WEAPP = '.wxml',
|
|
136
|
+
SWAN = '.swan',
|
|
137
|
+
ALIPAY = '.axml',
|
|
138
|
+
TT = '.ttml',
|
|
139
|
+
QUICKAPP = '.ux',
|
|
140
|
+
QQ = '.qml'
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export const enum STYLE_TYPES {
|
|
144
|
+
WEAPP = '.wxss',
|
|
145
|
+
SWAN = '.css',
|
|
146
|
+
ALIPAY = '.acss',
|
|
147
|
+
TT = '.ttss',
|
|
148
|
+
QUICKAPP = '.css',
|
|
149
|
+
QQ = '.qss'
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export const enum SCRIPT_TYPES {
|
|
153
|
+
WEAPP = '.js',
|
|
154
|
+
SWAN = '.js',
|
|
155
|
+
ALIPAY = '.js',
|
|
156
|
+
TT = '.js',
|
|
157
|
+
QUICKAPP = '.js',
|
|
158
|
+
QQ = '.js'
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export const enum CONFIG_TYPES {
|
|
162
|
+
WEAPP = '.json',
|
|
163
|
+
SWAN = '.json',
|
|
164
|
+
ALIPAY = '.json',
|
|
165
|
+
TT = '.json',
|
|
166
|
+
QUICKAPP = '.json',
|
|
167
|
+
QQ = '.json'
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export type IMINI_APP_FILE_TYPE = {
|
|
171
|
+
TEMPL: TEMPLATE_TYPES
|
|
172
|
+
STYLE: STYLE_TYPES
|
|
173
|
+
SCRIPT: SCRIPT_TYPES
|
|
174
|
+
CONFIG: CONFIG_TYPES
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export type IMINI_APP_FILES = {
|
|
178
|
+
[key: string]: IMINI_APP_FILE_TYPE
|
|
179
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type Tagname = string
|
|
2
|
+
type Attrs = Set<string>
|
|
3
|
+
|
|
4
|
+
export interface IComponentConfig {
|
|
5
|
+
includes: Set<string>
|
|
6
|
+
exclude: Set<string>
|
|
7
|
+
thirdPartyComponents: Map<Tagname, Attrs>
|
|
8
|
+
includeAll: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface IModifyChainData {
|
|
12
|
+
componentConfig?: IComponentConfig
|
|
13
|
+
}
|