(MpVue) applet code package size exceeds the limit of the solution

Click Preview, found it impossible to preview error:

Error: code package size is 3701 kb, an upper limit of 2048 kb, delete the file and try again

1. Load subcontracting

Modify app.json, increase subPackagesfield, probably a long way:

"subPackages": [
    {
      "root": "pages/cfs/",
      "pages": [
        "main",
        "query/main",
        "photograph/main",
        "packing/main",
        "pin/main",
        "pin/detail/main"
      ]
    },
    {
      "root": "pages/check/",
      "pages": [
        "main",
        "detail/main"
      ]
    }]
复制代码

My project directory like this:

2. Picture require

Found that the main package is still too big after the subcontractor / (¨Ò o ¨Ò) / ~ ~, before you think it should be my picture too much, and is introduced directly in the src years, then modified to use require()to introduce image resources :

{
  imgUrl: require('../../assets/images/home/cfs.png'),
  text: ''
},
 {
  imgUrl: require('../../assets/images/home/gate.png'),
  text: ''
},
 {
  imgUrl: require('../../assets/images/home/bay.png'),
  text: ''
},
 {
  imgUrl: require('../../assets/images/home/check.png'),
  text: ''
}
复制代码

The result is really the main package becomes small ha ha ha ha

Reproduced in: https: //juejin.im/post/5d08b1ebf265da1b95705973

Guess you like

Origin blog.csdn.net/weixin_33751566/article/details/93172461