@taro-minify-pack/preset 0.1.2 → 0.1.3-alpha.1
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 +18 -12
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
> 预设配置,整合了 @taro-minify-pack 系列核心插件,提供一键式优化解决方案,简化 Taro 项目的性能优化配置。
|
|
4
4
|
|
|
5
5
|
该预设包含以下插件:
|
|
6
|
+
|
|
6
7
|
- `@taro-minify-pack/plugin-async-pack`: 异步加载主包代码,优化主包体积
|
|
7
8
|
- `@taro-minify-pack/plugin-remote-assets`: 远程资源上传,优化主包体积
|
|
8
9
|
- `@taro-minify-pack/plugin-cover-browserslist`: 根据微信小程序基础库版本自动设置 browserslist
|
|
@@ -57,7 +58,7 @@ module.exports = {
|
|
|
57
58
|
```js
|
|
58
59
|
// config/index.js
|
|
59
60
|
const path = require('path')
|
|
60
|
-
const {
|
|
61
|
+
const {aliOssUploadAdapter} = require('@taro-minify-pack/preset')
|
|
61
62
|
|
|
62
63
|
module.exports = {
|
|
63
64
|
compiler: {
|
|
@@ -104,7 +105,7 @@ module.exports = {
|
|
|
104
105
|
```js
|
|
105
106
|
// config/index.js
|
|
106
107
|
const path = require('path')
|
|
107
|
-
const {
|
|
108
|
+
const {aliOssUploadAdapter} = require('@taro-minify-pack/remote-assets-adapter-ali-oss')
|
|
108
109
|
|
|
109
110
|
module.exports = {
|
|
110
111
|
compiler: {
|
|
@@ -134,12 +135,18 @@ module.exports = {
|
|
|
134
135
|
},
|
|
135
136
|
// 异步加载主包代码配置
|
|
136
137
|
asyncPack: {
|
|
137
|
-
// 框架类型,可选 'react' 或 'vue'
|
|
138
|
-
framework: 'react',
|
|
139
138
|
// 动态包名称前缀
|
|
140
|
-
dynamicPackageNamePrefix: 'dynamic-
|
|
139
|
+
dynamicPackageNamePrefix: 'dynamic-package',
|
|
141
140
|
// 动态包数量
|
|
142
|
-
dynamicPackageCount: 1
|
|
141
|
+
dynamicPackageCount: 1,
|
|
142
|
+
// 自定义异步分包
|
|
143
|
+
customDynamicPackages: [
|
|
144
|
+
{
|
|
145
|
+
name: 'report',
|
|
146
|
+
test: (module) => /src[\\/]pages[\\/]report[\\/]/.test(module.resource || ''),
|
|
147
|
+
asyncStyle: true
|
|
148
|
+
}
|
|
149
|
+
]
|
|
143
150
|
},
|
|
144
151
|
// 自动设置 browserslist 配置
|
|
145
152
|
coverBrowsersList: {
|
|
@@ -173,10 +180,11 @@ module.exports = {
|
|
|
173
180
|
|
|
174
181
|
### asyncPack 配置
|
|
175
182
|
|
|
176
|
-
| 选项名 | 类型
|
|
177
|
-
|
|
178
|
-
| dynamicPackageNamePrefix | `string`
|
|
179
|
-
| dynamicPackageCount | `number`
|
|
183
|
+
| 选项名 | 类型 | 默认值 | 描述 |
|
|
184
|
+
|--------------------------|--------------------------|---------------------|-----------|
|
|
185
|
+
| dynamicPackageNamePrefix | `string` | `'dynamic-package'` | 动态包名称前缀 |
|
|
186
|
+
| dynamicPackageCount | `number` | `1` | 动态包数量 |
|
|
187
|
+
| customDynamicPackages | `CustomDynamicPackage[]` | `[]` | 自定义异步分包配置 |
|
|
180
188
|
|
|
181
189
|
### remoteAssets 配置
|
|
182
190
|
|
|
@@ -223,8 +231,6 @@ module.exports = {
|
|
|
223
231
|
- **Taro < 4.0.10**:由于 `@tarojs/webpack5-runner` 不支持使用绝对路径注册 PostCSS 插件,在低版本 Taro 中直接使用本插件可能会导致插件无法生效。如需在低版本中使用,请参考官方 Pull Request( `https://github.com/NervJS/taro/pull/18683/files` ) 自行 patch。
|
|
224
232
|
- **Taro ≥ 4.0.10**:可直接使用,无需额外处理。
|
|
225
233
|
|
|
226
|
-
7. **async-pack 插件版本建议**:插件版本`0.0.5-alpha.x`尝试实现样式文件异步加载受微信机制影响存在无法优化的「闪屏样式丢失」,故`0.0.5`及以后版本不支持样式文件异步加载。
|
|
227
|
-
|
|
228
234
|
## 📄 许可证
|
|
229
235
|
|
|
230
236
|
MIT License
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taro-minify-pack/preset",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3-alpha.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"author": "yu.pan",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@taro-minify-pack/plugin-
|
|
19
|
-
"@taro-minify-pack/plugin-
|
|
20
|
-
"@taro-minify-pack/plugin-
|
|
21
|
-
"@taro-minify-pack/plugin-
|
|
18
|
+
"@taro-minify-pack/plugin-bundle-analyzer": "0.1.3-alpha.1",
|
|
19
|
+
"@taro-minify-pack/plugin-async-pack": "0.1.3-alpha.1",
|
|
20
|
+
"@taro-minify-pack/plugin-cover-browserslist": "0.1.3-alpha.1",
|
|
21
|
+
"@taro-minify-pack/plugin-remote-assets": "0.1.3-alpha.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^18.19.130",
|