-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
489 additions
and
756 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,6 +250,7 @@ module.exports = defineConfig({ | |
}) | ||
``` | ||
::: | ||
|
||
### externalClasses | ||
|
||
- **类型**:`Array<string>` | ||
|
@@ -488,6 +489,7 @@ module.exports = defineConfig({ | |
}) | ||
``` | ||
::: | ||
|
||
### autoSplit | ||
|
||
- **类型**:`boolean` | ||
|
@@ -1126,8 +1128,6 @@ module.exports = defineConfig({ | |
``` | ||
::: | ||
### i18n | ||
```js | ||
|
@@ -1404,6 +1404,82 @@ module.exports = defineConfig({ | |
该特性只能用于**开发环境**,默认情况下会阻止所有页面(**入口 app.mpx 除外**)的打包。 | ||
::: | ||
### asyncSubpackageRules | ||
- **类型**: | ||
```ts | ||
type Condition = string | Function | RegExp | ||
|
||
interface AsyncSubpackageRules { | ||
include: Condition | Array<Condition> | ||
exclude?: Condition | Array<Condition> | ||
root: string | ||
placeholder: string | { name: string, resource?: string} | ||
} | ||
``` | ||
* include: 同 webpack include 规则 | ||
* exclude: 同 webpack exclude 规则 | ||
* root: 匹配规则的组件或js模块的输出分包名 | ||
* placeholder: 匹配规则的组件所配置的componentPlaceholder,可支持配置原生组件和自定义组件,原生组件可直接以string类型配置,自定义组件需要配置对象,name 为该自定义组件名, resource 为自定义组件的路径,路径可为绝对路径和相对于项目目录的相对路径 | ||
- **详细**:异步分包场景下批量设置组件或 js 模块的异步分包,提升资源异步分包输出的灵活性。 | ||
- **示例**: | ||
```js | ||
// include 可以是正则、字符串、函数、数组 | ||
new MpxWebpackPlugin({ | ||
asyncSubpackageRules: [ | ||
{ | ||
include: '/project/pages', // 文件路径包含 '/project/pages' 的组件或者 require.async 异步引用的js 模块都会被打包至sub1分包 | ||
root: 'sub1', | ||
placeholder: 'view' | ||
} | ||
] | ||
}) | ||
// 若配置自定义组件 | ||
new MpxWebpackPlugin({ | ||
asyncSubpackageRules: [ | ||
{ | ||
include: '/project/pages', // 文件路径包含 '/project/pages' 的组件或者 require.async 异步引用的js 模块都会被打包至sub1分包 | ||
root: 'sub1', | ||
placeholder: { | ||
name: 'other-placeholder', | ||
resource: '/user/xxxx/other.mpx' // 自定义组件的绝对路径 | ||
} | ||
} | ||
] | ||
}) | ||
``` | ||
::: tip @mpxjs/[email protected] 版本配置如下 | ||
```js | ||
// vue.config.js | ||
module.exports = defineConfig({ | ||
pluginOptions: { | ||
mpx: { | ||
plugin: { | ||
// include 可以是正则、字符串、函数、数组 | ||
asyncSubpackageRules: [ | ||
{ | ||
include: '/project/pages', // 文件路径包含 '/project/pages' 的组件或者 require.async 异步引用的js 模块都会被打包至sub1分包 | ||
root: 'sub1', | ||
placeholder: 'view' | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}) | ||
``` | ||
::: | ||
:::warning | ||
* 该配置匹配的组件,若使用方在引用路径已设置?root或componentPlaceholder,则以引用路径中的?root或componentPlaceholder为最高优先级 | ||
* 若placeholder配置使用自定义组件,注意一定要配置 placeholder 中的 resource 字段 | ||
* 本功能只会对使用require.async异步引用的js模块生效,若引用路径中已配置?root,则以路径中?root优先 | ||
::: | ||
## MpxWebpackPlugin static methods | ||
`MpxWebpackPlugin` 通过静态方法暴露了以下五个内置 loader,详情如下: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
"packages": [ | ||
"packages/*" | ||
], | ||
"version": "2.8.40" | ||
"version": "2.8.47" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.