Skip to content

weapp-vite / WeappViteConfig

接口: WeappViteConfig

定义于: types/config.ts:314

属性

autoImportComponents?

optional autoImportComponents: AutoImportComponents

定义于: types/config.ts:435

自动导入小程序组件


autoRoutes?

optional autoRoutes: boolean

定义于: types/config.ts:327

Description

是否启用自动路由模块 (weapp-vite/auto-routes) 默认关闭,需要显式启用后才会扫描 pages/ 目录并生成路由清单。

默认值

ts
false

chunks?

optional chunks: ChunksConfig

定义于: types/config.ts:461

Description

共享代码拆分策略配置


copy?

optional copy: CopyOptions

定义于: types/config.ts:392

需要被额外包括的资源 默认情况下包括大部分的图片资源格式


debug?

optional debug: object

定义于: types/config.ts:443

inspect?

optional inspect: WrapPluginOptions

load()?

optional load: (id, subPackageMeta?) => void

参数
id

string

subPackageMeta?

SubPackageMetaValue

返回

void

resolveId()?

optional resolveId: (id, subPackageMeta?) => void

参数
id

string

subPackageMeta?

SubPackageMetaValue

返回

void

watchFiles()?

optional watchFiles: (watchFiles, subPackageMeta?) => void

参数
watchFiles

string[]

subPackageMeta?

SubPackageMetaValue

返回

void


enhance?

optional enhance: EnhanceOptions

定义于: types/config.ts:441

已被弃用

请改用顶层的 wxmlwxsautoImportComponents 增强配置


es5?

optional es5: boolean

定义于: types/config.ts:425

Description

是否启用基于 @swc/core 的 ES5 降级(仅支持 jsFormat: 'cjs'

默认值

ts
false

isAdditionalWxml()?

optional isAdditionalWxml: (wxmlFilePath) => boolean

定义于: types/config.ts:406

参数

wxmlFilePath

string

返回

boolean

boolean

Description

额外的 wxml 文件 把这个方法,扫描到的 wxml 添加到额外的 wxml 文件列表, 处理 之后输出到最终的产物中


jsFormat?

optional jsFormat: JsFormat

定义于: types/config.ts:420

Description

生成的 JS 模块格式

  • cjs: 输出 CommonJS
  • esm: 输出 ESM,需要在微信开发者工具中启用「ES6 转 ES5」

默认值

ts
'cjs'

pluginRoot?

optional pluginRoot: string

定义于: types/config.ts:333

Description

插件入口目录 (plugin.json 所在的目录)

默认值

ts
undefined

srcRoot?

optional srcRoot: string

定义于: types/config.ts:320

Description

应用入口目录 (app.json 所在的目录) 默认 js 模板在根目录 .,ts 模板在 miniprogram 目录,当然你可以把所有代码放在 src 目录下,并设置此选项为 src

默认值

ts
'.'

worker?

optional worker: object

定义于: types/config.ts:452

entry?

optional entry: string | string[]

Description

构建 worker 的入口

Description

构建 worker 配置


wxml?

optional wxml: boolean | Partial<Omit<EnhanceWxmlOptions, "platform">>

定义于: types/config.ts:427


wxs?

optional wxs: boolean

定义于: types/config.ts:431

wxs 增强

Web 运行时

浏览器端运行时相关配置

web?

optional web: WeappWebConfig

定义于: types/config.ts:398

json 配置

文件引入别名

jsonAlias?

optional jsonAlias: AliasOptions

定义于: types/config.ts:338

分包配置

分包是否独立的 rollup 编译上下文 默认情况下,当一个分包设置了 independent: true 之后会默认启用 可以设置 key: 为 root, value: {independent:true} 来强制启用 独立的 rollup 编译上下文

subPackages?

optional subPackages: Record<string, Pick<SubPackage, "independent" | "dependencies" | "inlineConfig"> & object>

定义于: types/config.ts:375

插件集成

传递给内置 vite-tsconfig-paths 插件的参数

tsconfigPaths?

optional tsconfigPaths: PluginOptions

定义于: types/config.ts:368

构建 npm

npm?

optional npm: object

定义于: types/config.ts:343

buildOptions()?

optional buildOptions: (options, pkgMeta) => Options | undefined

参数
options

Options

pkgMeta

BuildNpmPackageMeta

返回

Options | undefined

Description

构建 npm 的配置,可以配置这个选项给 tsdown,让不同的包走不同的配置

cache?

optional cache: boolean

Description

是否开启缓存,默认为 true

默认值
ts
true

enable?

optional enable: boolean

Description

是否开启构建 npm 功能, 默认为 true

默认值
ts
true

生成脚手架配置

weapp-vite generate 相关的配置

generate?

optional generate: GenerateOptions

定义于: types/config.ts:363

Released under the MIT License.