@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,134 @@
|
|
|
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 { IOption, IPostcssOption, IUrlLoaderOption } from './util'
|
|
6
|
+
import type { OutputOptions as RollupOutputOptions } from 'rollup'
|
|
7
|
+
import type { Compiler, CompilerTypes, CompilerWebpackTypes } from '../compiler'
|
|
8
|
+
import type { OutputExt } from './project'
|
|
9
|
+
import type { ServerOptions as ViteServerOptions } from 'vite'
|
|
10
|
+
|
|
11
|
+
export interface IH5RouterConfig {
|
|
12
|
+
/** 配置路由模式 */
|
|
13
|
+
mode?: 'hash' | 'browser' | 'multi'
|
|
14
|
+
/** 配置自定义路由 */
|
|
15
|
+
customRoutes?: IOption
|
|
16
|
+
/** 配置路由基准路径 */
|
|
17
|
+
basename?: string
|
|
18
|
+
lazyload?: boolean | ((pagename: string) => boolean)
|
|
19
|
+
renamePagename?: (pagename: string) => string
|
|
20
|
+
forcePath?: string
|
|
21
|
+
/** 加上这个参数,可以解决返回页面的时候白屏的问题,但是某些不支持 :has() 选择器的浏览器会有问题 */
|
|
22
|
+
enhanceAnimation?: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface IH5Config <T extends CompilerTypes = CompilerWebpackTypes> {
|
|
26
|
+
/** 设置输出解析文件的目录(默认值:'/')*/
|
|
27
|
+
publicPath?: string
|
|
28
|
+
|
|
29
|
+
/** h5 编译后的静态文件目录(默认值:'static') */
|
|
30
|
+
staticDirectory?: string
|
|
31
|
+
|
|
32
|
+
/** 编译后非 entry 的 js 文件的存放目录,主要影响动态引入的 pages 的存放路径(默认值:'chunk') */
|
|
33
|
+
chunkDirectory?: string
|
|
34
|
+
|
|
35
|
+
webpack?: ((webpackConfig: Webpack.Configuration, webpack) => Webpack.Configuration) | Webpack.Configuration
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 自定义 Webpack 配置
|
|
39
|
+
* @param chain [webpackChain](https://github.com/neutrinojs/webpack-chain) 对象
|
|
40
|
+
* @param webpack webpack 实例
|
|
41
|
+
*/
|
|
42
|
+
webpackChain?: (chain: Chain, webpack: typeof Webpack) => void
|
|
43
|
+
|
|
44
|
+
/** webpack 编译模式下,可用于修改、拓展 Webpack 的 output 选项,配置项参考[官方文档](https://webpack.js.org/configuration/output/)
|
|
45
|
+
* vite 编译模式下,用于修改、扩展 rollup 的 output,目前仅适配 chunkFileNames 和 assetFileNames 两个配置,修改其他配置请使用 vite 插件进行修改。配置想参考[官方文档](https://rollupjs.org/configuration-options/)
|
|
46
|
+
*/
|
|
47
|
+
output?: T extends 'vite'
|
|
48
|
+
? Pick<RollupOutputOptions, 'chunkFileNames' | 'assetFileNames'> & OutputExt
|
|
49
|
+
: Webpack.Configuration['output']
|
|
50
|
+
|
|
51
|
+
/** 路由相关的配置 */
|
|
52
|
+
router?: IH5RouterConfig
|
|
53
|
+
|
|
54
|
+
/** 预览服务的配置,可以更改端口等参数。具体配置参考 [webpack-dev-server](https://webpack.js.org/configuration/dev-server) */
|
|
55
|
+
// 修改后:同时支持 Webpack 和 Vite
|
|
56
|
+
devServer?: T extends 'vite' ? ViteServerOptions : webpackDevServer.Configuration
|
|
57
|
+
|
|
58
|
+
/** 用于控制是否生成 js、css 对应的 sourceMap (默认值:watch 模式下为 true,否则为 false) */
|
|
59
|
+
enableSourceMap?: boolean
|
|
60
|
+
|
|
61
|
+
/** 具体配置请参考 [Webpack devtool](https://webpack.js.org/configuration/devtool/#devtool) 配置 (默认值:'cheap-module-eval-source-map')*/
|
|
62
|
+
sourceMapType?:
|
|
63
|
+
| 'none'
|
|
64
|
+
| 'eval'
|
|
65
|
+
| 'cheap-eval-source-map'
|
|
66
|
+
| 'cheap-module-eval-source-map'
|
|
67
|
+
| 'eval-source-map'
|
|
68
|
+
| 'cheap-source-map'
|
|
69
|
+
| 'cheap-module-source-map'
|
|
70
|
+
| 'inline-cheap-source-map'
|
|
71
|
+
| 'inline-cheap-module-source-map'
|
|
72
|
+
| 'source-map'
|
|
73
|
+
| 'inline-source-map'
|
|
74
|
+
| 'hidden-source-map'
|
|
75
|
+
| 'nosources-source-map'
|
|
76
|
+
|
|
77
|
+
/** extract 功能开关,开启后将使用 mini-css-extract-plugin 分离 css 文件,可通过 h5.miniCssExtractPluginOption 对插件进行配置 (默认值:watch 模式下为 false,否则为 true) */
|
|
78
|
+
enableExtract?: boolean
|
|
79
|
+
|
|
80
|
+
/** [css-loader](https://github.com/webpack-contrib/css-loader) 的附加配置 */
|
|
81
|
+
cssLoaderOption?: IOption
|
|
82
|
+
|
|
83
|
+
/** [style-loader](https://github.com/webpack-contrib/style-loader) 的附加配置 */
|
|
84
|
+
styleLoaderOption?: IOption
|
|
85
|
+
|
|
86
|
+
/** [sass-loader](https://github.com/webpack-contrib/sass-loader) 的附加配置 */
|
|
87
|
+
sassLoaderOption?: IOption
|
|
88
|
+
|
|
89
|
+
/** [less-loader](https://github.com/webpack-contrib/less-loader) 的附加配置 */
|
|
90
|
+
lessLoaderOption?: IOption
|
|
91
|
+
|
|
92
|
+
/** [stylus-loader](https://github.com/shama/stylus-loader) 的附加配置 */
|
|
93
|
+
stylusLoaderOption?: IOption
|
|
94
|
+
|
|
95
|
+
/** 针对 mp4 | webm | ogg | mp3 | wav | flac | aac 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
|
|
96
|
+
mediaUrlLoaderOption?: IUrlLoaderOption
|
|
97
|
+
|
|
98
|
+
/** 针对 woff | woff2 | eot | ttf | otf 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
|
|
99
|
+
fontUrlLoaderOption?: IUrlLoaderOption
|
|
100
|
+
|
|
101
|
+
/** 针对 png | jpg | jpeg | gif | bpm | svg 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
|
|
102
|
+
imageUrlLoaderOption?: IUrlLoaderOption
|
|
103
|
+
|
|
104
|
+
/** [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) 的附加配置 */
|
|
105
|
+
miniCssExtractPluginOption?: IOption
|
|
106
|
+
|
|
107
|
+
/** 配置需要额外的经由 Taro 预设的 postcss 编译的模块 */
|
|
108
|
+
esnextModules?: string[]
|
|
109
|
+
|
|
110
|
+
/** 用于控制在 H5 端是否使用兼容性组件库,详情请看 [React 兼容性组件库](https://taro-docs.jd.com/docs/h5#react-兼容性组件库)。(默认值:false) */
|
|
111
|
+
useHtmlComponents?: boolean
|
|
112
|
+
|
|
113
|
+
/** 用于控制在 H5 端是否使用旧版本适配器,旧版本采用全局注册组件,懒加载组件相关依赖;新版本适配器会自动注册相关组件,不再需要引入 @spcsn/taro-components/loader 中的全局 defineCustomElements 方法。(默认值:false) */
|
|
114
|
+
useDeprecatedAdapterComponent?: boolean
|
|
115
|
+
|
|
116
|
+
/** 配置 postcss 相关插件 */
|
|
117
|
+
postcss?: IPostcssOption<'h5'>
|
|
118
|
+
|
|
119
|
+
/** html-webpack-plugin 的具体配置 */
|
|
120
|
+
htmlPluginOption?: HtmlWebpackPlugin.Options
|
|
121
|
+
|
|
122
|
+
/** Web 编译过程的相关配置 */
|
|
123
|
+
compile?: {
|
|
124
|
+
exclude?: any[]
|
|
125
|
+
include?: any[]
|
|
126
|
+
/** 对应 Babel transform 插件的 filter 配置。只在 vite 编译模式下有效 */
|
|
127
|
+
filter?: (filename: string) => boolean
|
|
128
|
+
}
|
|
129
|
+
/** 生成的代码是否要兼容旧版浏览器,值为 true 时,会去读取 package.json 的 browserslist 字段。只在 vite 编译模式下有效 */
|
|
130
|
+
legacy?: T extends 'vite' ? boolean : undefined
|
|
131
|
+
|
|
132
|
+
/** 使用的编译工具。可选值:webpack5、vite */
|
|
133
|
+
compiler?: Compiler<T>
|
|
134
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { OutputOptions as RollupOutputOptions } from 'rollup'
|
|
2
|
+
import type Webpack from 'webpack'
|
|
3
|
+
import type Chain from 'webpack-chain'
|
|
4
|
+
|
|
5
|
+
import type { IOption, IPostcssOption, IUrlLoaderOption } from './util'
|
|
6
|
+
import type { CompilerTypes, CompilerWebpackTypes } from '../compiler'
|
|
7
|
+
import type { OutputExt } from './project'
|
|
8
|
+
|
|
9
|
+
export interface IHarmonyRouterConfig {
|
|
10
|
+
/** 配置自定义路由 */
|
|
11
|
+
customRoutes?: IOption
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface IHarmonyConfig<T extends CompilerTypes = 'vite'> {
|
|
15
|
+
/** Harmony 项目地址 */
|
|
16
|
+
projectPath: string
|
|
17
|
+
|
|
18
|
+
/** hap 名
|
|
19
|
+
* @default "entry"
|
|
20
|
+
*/
|
|
21
|
+
hapName?: string
|
|
22
|
+
|
|
23
|
+
/** 应用名称
|
|
24
|
+
* @default "default"
|
|
25
|
+
*/
|
|
26
|
+
name?: string
|
|
27
|
+
|
|
28
|
+
/** oh-package.json 配置 */
|
|
29
|
+
ohPackage?: {
|
|
30
|
+
dependencies?: { [name: string]: string }
|
|
31
|
+
devDependencies?: { [name: string]: string }
|
|
32
|
+
main?: string
|
|
33
|
+
[k: string]: any
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** ohpm-cli
|
|
37
|
+
* @default "~/Library/Huawei/ohpm/bin/ohpm"
|
|
38
|
+
*/
|
|
39
|
+
ohpm?: string
|
|
40
|
+
|
|
41
|
+
/** 核心依赖前缀
|
|
42
|
+
* @description 用于告诉编译内容如何解析核心依赖,传入时将直接使用依赖前缀,同时不会为工程导入核心依赖
|
|
43
|
+
*/
|
|
44
|
+
chorePackagePrefix?: string
|
|
45
|
+
|
|
46
|
+
/** 用于告诉 Taro 编译器需要抽取的公共文件 */
|
|
47
|
+
commonChunks?: string[] | ((commonChunks: string[]) => string[])
|
|
48
|
+
|
|
49
|
+
/** Harmony 编译过程的相关配置 */
|
|
50
|
+
compile?: {
|
|
51
|
+
exclude?: any[]
|
|
52
|
+
include?: any[]
|
|
53
|
+
filter?: (filename: string) => boolean
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** 用于配置半编译模式下的选项 */
|
|
57
|
+
compileModeSetting?: {
|
|
58
|
+
componentReplace?: {
|
|
59
|
+
[key: string]: {
|
|
60
|
+
current_init: string
|
|
61
|
+
dependency_define: string
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** 用于控制是否生成 js、css 对应的 sourceMap (默认值:watch 模式下为 true,否则为 false) */
|
|
67
|
+
enableSourceMap?: boolean
|
|
68
|
+
|
|
69
|
+
/** 默认值:'cheap-module-source-map', 具体参考[Webpack devtool 配置](https://webpack.js.org/configuration/devtool/#devtool) */
|
|
70
|
+
sourceMapType?: string
|
|
71
|
+
|
|
72
|
+
/** 指定 React 框架相关的代码是否使用开发环境(未压缩)代码,默认使用生产环境(压缩后)代码 */
|
|
73
|
+
debugReact?: boolean
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 自定义 Webpack 配置
|
|
77
|
+
* @param chain [webpackChain](https://github.com/neutrinojs/webpack-chain) 对象
|
|
78
|
+
* @param webpack webpack 实例
|
|
79
|
+
*/
|
|
80
|
+
webpackChain?: (chain: Chain, webpack: typeof Webpack) => void
|
|
81
|
+
|
|
82
|
+
/** webpack 编译模式下,可用于修改、拓展 Webpack 的 output 选项,配置项参考[官方文档](https://webpack.js.org/configuration/output/)
|
|
83
|
+
* vite 编译模式下,用于修改、扩展 rollup 的 output,目前仅适配 chunkFileNames 和 assetFileNames 两个配置,修改其他配置请使用 vite 插件进行修改。配置想参考[官方文档](https://rollupjs.org/configuration-options/)
|
|
84
|
+
*/
|
|
85
|
+
output?: T extends 'vite'
|
|
86
|
+
? Pick<RollupOutputOptions, 'chunkFileNames'> & OutputExt
|
|
87
|
+
: Webpack.Configuration['output'] & OutputExt
|
|
88
|
+
|
|
89
|
+
/** 路由相关的配置 */
|
|
90
|
+
router?: IHarmonyRouterConfig
|
|
91
|
+
|
|
92
|
+
/** 配置 postcss 相关插件 */
|
|
93
|
+
postcss?: IPostcssOption<'harmony'>
|
|
94
|
+
|
|
95
|
+
/** [css-loader](https://github.com/webpack-contrib/css-loader) 的附加配置 */
|
|
96
|
+
cssLoaderOption?: IOption
|
|
97
|
+
|
|
98
|
+
/** [sass-loader](https://github.com/webpack-contrib/sass-loader) 的附加配置 */
|
|
99
|
+
sassLoaderOption?: IOption
|
|
100
|
+
|
|
101
|
+
/** [less-loader](https://github.com/webpack-contrib/less-loader) 的附加配置 */
|
|
102
|
+
lessLoaderOption?: IOption
|
|
103
|
+
|
|
104
|
+
/** [stylus-loader](https://github.com/shama/stylus-loader) 的附加配置 */
|
|
105
|
+
stylusLoaderOption?: IOption
|
|
106
|
+
|
|
107
|
+
/** 针对 mp4 | webm | ogg | mp3 | wav | flac | aac 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
|
|
108
|
+
mediaUrlLoaderOption?: IUrlLoaderOption
|
|
109
|
+
|
|
110
|
+
/** 针对 woff | woff2 | eot | ttf | otf 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
|
|
111
|
+
fontUrlLoaderOption?: IUrlLoaderOption
|
|
112
|
+
|
|
113
|
+
/** 针对 png | jpg | jpeg | gif | bpm | svg 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
|
|
114
|
+
imageUrlLoaderOption?: IUrlLoaderOption
|
|
115
|
+
|
|
116
|
+
/** [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) 的附加配置 */
|
|
117
|
+
miniCssExtractPluginOption?: IOption
|
|
118
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import type { IOption } from './util'
|
|
2
|
+
|
|
3
|
+
type FeatureItem = {
|
|
4
|
+
name: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare enum LogLevel {
|
|
8
|
+
OFF = 'off',
|
|
9
|
+
ERROR = 'error',
|
|
10
|
+
WARN = 'warn',
|
|
11
|
+
INFO = 'info',
|
|
12
|
+
LOG = 'log',
|
|
13
|
+
DEBUG = 'debug'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type SystemConfig = {
|
|
17
|
+
/**
|
|
18
|
+
* 打印日志等级,分为 off,error,warn,info,log,debug
|
|
19
|
+
*/
|
|
20
|
+
logLevel?: LogLevel
|
|
21
|
+
/**
|
|
22
|
+
* 页面设计基准宽度,根据实际设备宽度来缩放元素大小
|
|
23
|
+
*/
|
|
24
|
+
designWidth?: number
|
|
25
|
+
/**
|
|
26
|
+
* 全局数据对象,属性名不能以$或_开头,在页面中可通过 this 进行访问;如果全局数据属性与页面的数据属性重名,则页面初始化时,全局数据会覆盖页面中对应的属性值
|
|
27
|
+
*/
|
|
28
|
+
data?: IOption
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type RouterConfig = {
|
|
32
|
+
/**
|
|
33
|
+
* 首页名称
|
|
34
|
+
*/
|
|
35
|
+
entry: string
|
|
36
|
+
/**
|
|
37
|
+
* 页面配置列表,key 值为页面名称(对应页面目录名,例如 Hello 对应'Hello'目录),value 为页面详细配置 page
|
|
38
|
+
*/
|
|
39
|
+
pages: RouterPage[]
|
|
40
|
+
}
|
|
41
|
+
type RouterPage = {
|
|
42
|
+
/**
|
|
43
|
+
* 页面对应的组件名,与 ux 文件名保持一致,例如'hello' 对应 'hello.ux'
|
|
44
|
+
*/
|
|
45
|
+
component: string
|
|
46
|
+
/**
|
|
47
|
+
* 页面路径,例如“/user”,不填则默认为/<页面名称>。
|
|
48
|
+
* path 必须唯一,不能和其他 page 的 path 相同。
|
|
49
|
+
* 下面 page 的 path 因为缺失,会被设置为“/Index”:
|
|
50
|
+
* "Index": {"component": "index"}
|
|
51
|
+
*/
|
|
52
|
+
path?: string
|
|
53
|
+
/**
|
|
54
|
+
* 声明页面可以处理某种请求
|
|
55
|
+
*/
|
|
56
|
+
filter: {
|
|
57
|
+
[key: string]: {
|
|
58
|
+
uri: string
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface IDefaultDisplayConfig {
|
|
64
|
+
/**
|
|
65
|
+
* 窗口背景颜色
|
|
66
|
+
*/
|
|
67
|
+
backgroundColor?: string
|
|
68
|
+
/**
|
|
69
|
+
* 是否是全屏模式,默认不会同时作用于 titleBar,titleBar 需要继续通过 titleBar 控制
|
|
70
|
+
*/
|
|
71
|
+
fullScreen?: boolean
|
|
72
|
+
/**
|
|
73
|
+
* 是否显示 titleBar
|
|
74
|
+
*/
|
|
75
|
+
titleBar?: boolean
|
|
76
|
+
/**
|
|
77
|
+
* 标题栏背景色
|
|
78
|
+
*/
|
|
79
|
+
titleBarBackgroundColor?: string
|
|
80
|
+
/**
|
|
81
|
+
* 标题栏文字颜色
|
|
82
|
+
*/
|
|
83
|
+
titleBarTextColor?: string
|
|
84
|
+
/**
|
|
85
|
+
* 标题栏文字(也可通过页面跳转传递参数(titleBarText)设置)
|
|
86
|
+
*/
|
|
87
|
+
titleBarText?: string
|
|
88
|
+
/**
|
|
89
|
+
* 是否显示标题栏右上角菜单按钮,点击菜单按钮调用页面生命周期 onMenuPress 方法,如果该方法未实现则显示系统默认菜单
|
|
90
|
+
*/
|
|
91
|
+
menu?: boolean
|
|
92
|
+
/**
|
|
93
|
+
* 软键盘弹出时为保证输入框可见,页面的调整方式。 adjustPan:上移页面; adjustResize:压缩页面显示区域,当页面全屏时,此设置不生效
|
|
94
|
+
*/
|
|
95
|
+
windowSoftInputMode?: 'adjustPan' | 'adjustResize'
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
interface IDisplayConfig extends IDefaultDisplayConfig {
|
|
99
|
+
/**
|
|
100
|
+
* 各个页面的显示样式,key 为页面名(与路由中的页面名保持一致),value 为窗口显示样式,页面样式覆盖 default 样式
|
|
101
|
+
*/
|
|
102
|
+
pages?: {
|
|
103
|
+
[key: string]: IDefaultDisplayConfig
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface ITaroManifestConfig {
|
|
108
|
+
/**
|
|
109
|
+
* 应用包名,确认与原生应用的包名不一致,推荐采用 com.company.module 的格式,如:com.example.demo
|
|
110
|
+
*/
|
|
111
|
+
package: string
|
|
112
|
+
/**
|
|
113
|
+
* 应用名称,6 个汉字以内,与应用商店保存的名称一致,用于在桌面图标、弹窗等处显示应用名称
|
|
114
|
+
*/
|
|
115
|
+
name: string
|
|
116
|
+
/**
|
|
117
|
+
* 应用图标,提供 192x192 大小的即可
|
|
118
|
+
*/
|
|
119
|
+
icon: string
|
|
120
|
+
/**
|
|
121
|
+
* 应用版本名称,如:"1.0"
|
|
122
|
+
*/
|
|
123
|
+
versionName?: string
|
|
124
|
+
/**
|
|
125
|
+
* 应用版本号,从1自增,推荐每次重新上传包时versionCode+1
|
|
126
|
+
*/
|
|
127
|
+
versionCode: number
|
|
128
|
+
/**
|
|
129
|
+
* 支持的最小平台版本号,兼容性检查,避免上线后在低版本平台运行并导致不兼容;如果不填按照内测版本处理
|
|
130
|
+
*/
|
|
131
|
+
minPlatformVersion?: string
|
|
132
|
+
/**
|
|
133
|
+
* 接口列表,绝大部分接口都需要在这里声明,否则不能调用,详见每个接口的文档说明
|
|
134
|
+
*/
|
|
135
|
+
features?: FeatureItem[]
|
|
136
|
+
/**
|
|
137
|
+
*
|
|
138
|
+
*/
|
|
139
|
+
logLevel?: LogLevel
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface IManifestConfig extends ITaroManifestConfig {
|
|
143
|
+
/**
|
|
144
|
+
* 系统配置信息
|
|
145
|
+
*/
|
|
146
|
+
config: SystemConfig
|
|
147
|
+
/**
|
|
148
|
+
* 路由信息
|
|
149
|
+
*/
|
|
150
|
+
router: RouterConfig
|
|
151
|
+
/**
|
|
152
|
+
* UI 显示相关配置
|
|
153
|
+
*/
|
|
154
|
+
display?: IDisplayConfig
|
|
155
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type Webpack from 'webpack'
|
|
2
|
+
import type Chain from 'webpack-chain'
|
|
3
|
+
import type { IOption, IPostcssOption, IUrlLoaderOption } from './util'
|
|
4
|
+
import type { OutputOptions as RollupOutputOptions } from 'rollup'
|
|
5
|
+
import type { Compiler, CompilerTypes, CompilerWebpackTypes } from '../compiler'
|
|
6
|
+
import type { OutputExt } from './project'
|
|
7
|
+
|
|
8
|
+
interface Runtime {
|
|
9
|
+
enableSizeAPIs?: boolean
|
|
10
|
+
enableTemplateContent?: boolean
|
|
11
|
+
enableCloneNode?: boolean
|
|
12
|
+
enableContains?: boolean
|
|
13
|
+
enableMutationObserver?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface IMiniAppConfig<T extends CompilerTypes = CompilerWebpackTypes> {
|
|
17
|
+
/** 用于控制是否生成 js、css 对应的 sourceMap (默认值:watch 模式下为 true,否则为 false) */
|
|
18
|
+
enableSourceMap?: boolean
|
|
19
|
+
|
|
20
|
+
/** 默认值:'cheap-module-source-map', 具体参考[Webpack devtool 配置](https://webpack.js.org/configuration/devtool/#devtool) */
|
|
21
|
+
sourceMapType?: string
|
|
22
|
+
|
|
23
|
+
/** 指定 React 框架相关的代码是否使用开发环境(未压缩)代码,默认使用生产环境(压缩后)代码 */
|
|
24
|
+
debugReact?: boolean
|
|
25
|
+
|
|
26
|
+
/** 是否跳过第三方依赖 usingComponent 的处理,默认为自动处理第三方依赖的自定义组件 */
|
|
27
|
+
skipProcessUsingComponents?: boolean
|
|
28
|
+
|
|
29
|
+
/** 压缩小程序 xml 文件的相关配置 */
|
|
30
|
+
minifyXML?: {
|
|
31
|
+
/** 是否合并 xml 文件中的空格 (默认false) */
|
|
32
|
+
collapseWhitespace?: boolean
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 自定义 Webpack 配置
|
|
37
|
+
* @param chain [webpackChain](https://github.com/neutrinojs/webpack-chain) 对象
|
|
38
|
+
* @param webpack webpack 实例
|
|
39
|
+
* @param PARSE_AST_TYPE 小程序编译时的文件类型集合
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
webpackChain?: (chain: Chain, webpack: typeof Webpack, PARSE_AST_TYPE: any) => void
|
|
43
|
+
|
|
44
|
+
/** webpack 编译模式下,可用于修改、拓展 Webpack 的 output 选项,配置项参考[官方文档](https://webpack.js.org/configuration/output/)
|
|
45
|
+
* vite 编译模式下,用于修改、扩展 rollup 的 output,目前仅适配 chunkFileNames 和 assetFileNames 两个配置,修改其他配置请使用 vite 插件进行修改。配置想参考[官方文档](https://rollupjs.org/configuration-options/)
|
|
46
|
+
*/
|
|
47
|
+
output?: T extends 'vite'
|
|
48
|
+
? Pick<RollupOutputOptions, 'chunkFileNames'> & OutputExt
|
|
49
|
+
: Webpack.Configuration['output'] & OutputExt
|
|
50
|
+
|
|
51
|
+
/** 配置 postcss 相关插件 */
|
|
52
|
+
postcss?: IPostcssOption<'mini'>
|
|
53
|
+
|
|
54
|
+
/** [css-loader](https://github.com/webpack-contrib/css-loader) 的附加配置 */
|
|
55
|
+
cssLoaderOption?: IOption
|
|
56
|
+
|
|
57
|
+
/** [sass-loader](https://github.com/webpack-contrib/sass-loader) 的附加配置 */
|
|
58
|
+
sassLoaderOption?: IOption
|
|
59
|
+
|
|
60
|
+
/** [less-loader](https://github.com/webpack-contrib/less-loader) 的附加配置 */
|
|
61
|
+
lessLoaderOption?: IOption
|
|
62
|
+
|
|
63
|
+
/** [stylus-loader](https://github.com/shama/stylus-loader) 的附加配置 */
|
|
64
|
+
stylusLoaderOption?: IOption
|
|
65
|
+
|
|
66
|
+
/** 针对 mp4 | webm | ogg | mp3 | wav | flac | aac 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
|
|
67
|
+
mediaUrlLoaderOption?: IUrlLoaderOption
|
|
68
|
+
|
|
69
|
+
/** 针对 woff | woff2 | eot | ttf | otf 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
|
|
70
|
+
fontUrlLoaderOption?: IUrlLoaderOption
|
|
71
|
+
|
|
72
|
+
/** 针对 png | jpg | jpeg | gif | bpm | svg 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
|
|
73
|
+
imageUrlLoaderOption?: IUrlLoaderOption
|
|
74
|
+
|
|
75
|
+
/** [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) 的附加配置 */
|
|
76
|
+
miniCssExtractPluginOption?: IOption
|
|
77
|
+
|
|
78
|
+
/** 用于告诉 Taro 编译器需要抽取的公共文件 */
|
|
79
|
+
commonChunks?: string[] | ((commonChunks: string[]) => string[])
|
|
80
|
+
|
|
81
|
+
/** 为某些页面单独指定需要引用的公共文件 */
|
|
82
|
+
addChunkPages?: (pages: Map<string, string[]>, pagesNames?: string[]) => void
|
|
83
|
+
|
|
84
|
+
/** 优化主包的体积大小 */
|
|
85
|
+
optimizeMainPackage?: {
|
|
86
|
+
enable?: boolean
|
|
87
|
+
exclude?: any[]
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** 小程序编译过程的相关配置 */
|
|
91
|
+
compile?: {
|
|
92
|
+
exclude?: any[]
|
|
93
|
+
include?: any[]
|
|
94
|
+
/** 对应 Babel transform 插件的 filter 配置。只在 vite 编译模式下有效 */
|
|
95
|
+
filter?: (filename: string) => boolean
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** 插件内部使用 */
|
|
99
|
+
runtime?: Runtime
|
|
100
|
+
|
|
101
|
+
/** 使用的编译工具。可选值:webpack5、vite */
|
|
102
|
+
compiler?: Compiler<T>
|
|
103
|
+
|
|
104
|
+
/** 体验式功能 */
|
|
105
|
+
experimental?: {
|
|
106
|
+
/** 是否开启编译模式 */
|
|
107
|
+
compileMode?: boolean | string
|
|
108
|
+
/** 模版渲染时是否使用wxs等小程序脚本语言 */
|
|
109
|
+
useXsForTemplate?: boolean
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface IMiniFilesConfig {
|
|
114
|
+
[configName: string]: {
|
|
115
|
+
content: any
|
|
116
|
+
path: string
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CustomPluginOptions, ResolvedId, ResolveIdResult } from 'rollup'
|
|
2
|
+
|
|
3
|
+
interface IRollupPluginResolveIdOptions {
|
|
4
|
+
assertions?: Record<string, string>
|
|
5
|
+
custom?: CustomPluginOptions
|
|
6
|
+
isEntry?: boolean
|
|
7
|
+
skipSelf?: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type TRollupResolveMethod = (
|
|
11
|
+
source: string,
|
|
12
|
+
importer?: string,
|
|
13
|
+
options?: IRollupPluginResolveIdOptions
|
|
14
|
+
) => Promise<ResolvedId | null>
|
|
15
|
+
|
|
16
|
+
export interface ILoaderMeta {
|
|
17
|
+
importFrameworkStatement: string
|
|
18
|
+
importFrameworkName: string
|
|
19
|
+
creator: string
|
|
20
|
+
creatorLocation: string
|
|
21
|
+
extraImportForWeb: string
|
|
22
|
+
execBeforeCreateWebApp: string
|
|
23
|
+
frameworkArgs: string
|
|
24
|
+
isNeedRawLoader?: boolean
|
|
25
|
+
mockAppStatement: string
|
|
26
|
+
modifyConfig?: (config: Record<string, any>, source: string) => void
|
|
27
|
+
modifyResolveId?: (res: {
|
|
28
|
+
source?: string
|
|
29
|
+
importer?: string
|
|
30
|
+
options?: IRollupPluginResolveIdOptions
|
|
31
|
+
name?: string
|
|
32
|
+
resolve: TRollupResolveMethod
|
|
33
|
+
}) => Promise<ResolveIdResult> | ResolveIdResult
|
|
34
|
+
}
|