@taro-minify-pack/preset 0.0.1 → 0.0.3

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.
Files changed (2) hide show
  1. package/README.md +72 -0
  2. package/package.json +4 -4
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ ## @taro-minify-pack/preset
2
+ > 预设配置, 包含 `@taro-minify-pack/plugin-async-pack` 和 `@taro-minify-pack/plugin-remote-assets`
3
+
4
+ ### 安装
5
+
6
+ #### npm 安装
7
+ ```bash
8
+ npm install @taro-minify-pack/preset
9
+ ```
10
+ #### yarn 安装
11
+ ```bash
12
+ yarn add @taro-minify-pack/preset
13
+ ```
14
+
15
+ #### pnpm 安装
16
+ ```bash
17
+ pnpm add @taro-minify-pack/preset
18
+ ```
19
+
20
+ ### 配置
21
+
22
+ #### `babel`配置
23
+ ```ts
24
+ // babel-preset-taro 更多选项和默认值:
25
+ // https://docs.taro.zone/docs/next/babel-config
26
+ module.exports = {
27
+ presets: [
28
+ ['taro', {
29
+ framework: 'react',
30
+ ts: true,
31
+ compiler: 'webpack5',
32
+ // 在原有基础上添加这个配置即可
33
+ 'dynamic-import-node': process.env.TARO_ENV !== 'weapp',
34
+ }]
35
+ ]
36
+ }
37
+ ```
38
+ #### `Taro` 配置
39
+ ```js
40
+ // config/index.js
41
+ module.exports = {
42
+ compiler: {
43
+ type: 'webpack5',
44
+ prebundle: {
45
+ // 关闭预打包,这里和分包异步编译有冲突,当然如果只是 production 环境用异步分包的话就无所谓了
46
+ enable: false,
47
+ }
48
+ },
49
+ presets: [
50
+ ['@taro-minify-pack/preset', {
51
+ // 开启远程资源上传, 优化主包体积,与 `@taro-minify-pack/plugin-remote-assets` 插件配置一致
52
+ remoteAssets: {
53
+ pathAlias: {
54
+ '@': path.resolve(__dirname, '../src/'),
55
+ '~@': path.resolve(__dirname, '../src/'),
56
+ },
57
+ assetsDirPath: path.resolve(__dirname, '../src/assets/'),
58
+ uploader: aliOssUploadAdapter({
59
+ customDomain:'https://your-custom-domain.com',
60
+ accessKeyId: 'your-access-key-id',
61
+ accessKeySecret: 'your-access-key-secret',
62
+ bucket: 'your-bucket-name',
63
+ bucketDir: 'bucketDir',
64
+ region: 'your-region',
65
+ })
66
+ },
67
+ // 开启异步加载主包代码, 优化主包体积,也可以自定义与 `@taro-minify-pack/plugin-async-pack` 插件配置一致
68
+ asyncPack: true
69
+ }],
70
+ ],
71
+ };
72
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taro-minify-pack/preset",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,10 +13,10 @@
13
13
  "url": "git+https://github.com/panyu97py/taro-minify-pack.git"
14
14
  },
15
15
  "author": "yu.pan",
16
- "license": "ISC",
16
+ "license": "MIT",
17
17
  "dependencies": {
18
- "@taro-minify-pack/plugin-async-pack": "0.0.1",
19
- "@taro-minify-pack/plugin-remote-assets": "0.0.1"
18
+ "@taro-minify-pack/plugin-async-pack": "0.0.3",
19
+ "@taro-minify-pack/plugin-remote-assets": "0.0.3"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/node": "^18.19.130",