@taro-minify-pack/preset 0.0.5-alpha.6 → 0.0.5
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 +16 -13
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -19,18 +19,15 @@
|
|
|
19
19
|
|
|
20
20
|
## 📦 安装
|
|
21
21
|
|
|
22
|
-
### 必需依赖安装
|
|
23
|
-
使用该预设时,需要同时安装 `@taro-minify-pack/react-lazy-enhanced` 包以支持异步组件加载:
|
|
24
|
-
|
|
25
22
|
```bash
|
|
26
23
|
# 使用 npm
|
|
27
|
-
npm install @taro-minify-pack/preset
|
|
24
|
+
npm install @taro-minify-pack/preset
|
|
28
25
|
|
|
29
26
|
# 使用 yarn
|
|
30
|
-
yarn add @taro-minify-pack/preset
|
|
27
|
+
yarn add @taro-minify-pack/preset
|
|
31
28
|
|
|
32
29
|
# 使用 pnpm
|
|
33
|
-
pnpm add @taro-minify-pack/preset
|
|
30
|
+
pnpm add @taro-minify-pack/preset
|
|
34
31
|
```
|
|
35
32
|
|
|
36
33
|
## 🛠️ 配置
|
|
@@ -60,7 +57,7 @@ module.exports = {
|
|
|
60
57
|
```js
|
|
61
58
|
// config/index.js
|
|
62
59
|
const path = require('path')
|
|
63
|
-
const { aliOssUploadAdapter } = require('@taro-minify-pack/
|
|
60
|
+
const { aliOssUploadAdapter } = require('@taro-minify-pack/preset')
|
|
64
61
|
|
|
65
62
|
module.exports = {
|
|
66
63
|
compiler: {
|
|
@@ -137,6 +134,8 @@ module.exports = {
|
|
|
137
134
|
},
|
|
138
135
|
// 异步加载主包代码配置
|
|
139
136
|
asyncPack: {
|
|
137
|
+
// 框架类型,可选 'react' 或 'vue'
|
|
138
|
+
framework: 'react',
|
|
140
139
|
// 动态包名称前缀
|
|
141
140
|
dynamicPackageNamePrefix: 'dynamic-common',
|
|
142
141
|
// 动态包数量
|
|
@@ -210,17 +209,21 @@ module.exports = {
|
|
|
210
209
|
|
|
211
210
|
## ⚠️ 注意事项
|
|
212
211
|
|
|
213
|
-
1.
|
|
212
|
+
1. **预打包冲突**:当启用 `asyncPack` 时,必须关闭 Taro 的预打包功能(`compiler.prebundle.enable = false`),否则会导致构建冲突。
|
|
213
|
+
|
|
214
|
+
2. **Babel 配置**:必须在 Babel 配置中添加 `'dynamic-import-node': process.env.TARO_ENV !== 'weapp'`,以确保异步加载功能在不同环境下正常工作。
|
|
214
215
|
|
|
215
|
-
|
|
216
|
+
3. **远程资源上传**:使用 `remoteAssets` 时,需要提供有效的上传适配器和配置信息,确保资源能够正确上传到远程服务器。
|
|
216
217
|
|
|
217
|
-
|
|
218
|
+
4. **基础库版本**:使用 `coverBrowsersList` 时,必须指定正确的微信小程序基础库版本,以确保生成的代码兼容目标环境。
|
|
218
219
|
|
|
219
|
-
|
|
220
|
+
5. **Webpack 版本**:该预设仅支持 Webpack 5 编译器,请确保 Taro 项目使用 `compiler.type = 'webpack5'`。
|
|
220
221
|
|
|
221
|
-
|
|
222
|
+
6. **remote-assets 插件版本兼容性**:
|
|
223
|
+
- **Taro < 4.0.10**:由于 `@tarojs/webpack5-runner` 不支持使用绝对路径注册 PostCSS 插件,在低版本 Taro 中直接使用本插件可能会导致插件无法生效。如需在低版本中使用,请参考官方 Pull Request( `https://github.com/NervJS/taro/pull/18683/files` ) 自行 patch。
|
|
224
|
+
- **Taro ≥ 4.0.10**:可直接使用,无需额外处理。
|
|
222
225
|
|
|
223
|
-
|
|
226
|
+
7. **async-pack 插件版本建议**:插件版本`0.0.5-alpha.x`尝试实现样式文件异步加载受微信机制影响存在无法优化的「闪屏样式丢失」,故`0.0.5`及以后版本不支持样式文件异步加载。
|
|
224
227
|
|
|
225
228
|
## 📄 许可证
|
|
226
229
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taro-minify-pack/preset",
|
|
3
|
-
"version": "0.0.5
|
|
3
|
+
"version": "0.0.5",
|
|
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-remote-assets": "0.0.5
|
|
21
|
-
"@taro-minify-pack/plugin-
|
|
18
|
+
"@taro-minify-pack/plugin-async-pack": "0.0.5",
|
|
19
|
+
"@taro-minify-pack/plugin-bundle-analyzer": "0.0.5",
|
|
20
|
+
"@taro-minify-pack/plugin-remote-assets": "0.0.5",
|
|
21
|
+
"@taro-minify-pack/plugin-cover-browserslist": "0.0.5"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^18.19.130",
|