Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

前端打包js文件太大(7M),造成第一次访问速度太慢(60秒以上) #1343

Closed
224148793 opened this issue Jun 16, 2020 · 15 comments

Comments

@224148793
Copy link

版本号:

2.2.0

问题描述:

前端打包js文件太大(7M),造成第一次访问速度太慢(60秒以上)

截图&代码:

image
image

友情提示: 未按格式要求发帖,会直接删掉。

@224148793
Copy link
Author

可能还是我没有表述清楚吧,我不是说整个dist文件夹打包是7M,我是我生成的有一个js文件是7M。可以看前面的图片。chunk-vendors.ee53c28d.js 这个文件有7M,然后gzip以后是2.5M。谢谢。

@zhangdaiscott
Copy link
Member

zhangdaiscott commented Jun 16, 2020

打包过大已确认是依赖"@jeecg/antd-online-beta220": "^1.0.1"的问题。
如果发布线上不需要online功能,可以把此依赖删掉会小非常多 测试结果:chunk-vendors*.js变成2.6M、然后gzip以后是810 KB

具体操作步骤

1、package.json 删掉依赖 @jeecg/antd-online-beta220
2、yarn install 或者cnpm install
3、执行打包build命令

image

@jeecgboot jeecgboot deleted a comment from 224148793 Jun 23, 2020
@jeecgboot jeecgboot deleted a comment from 224148793 Jun 23, 2020
@jeecgboot jeecgboot deleted a comment from 224148793 Jun 23, 2020
@jeecgboot jeecgboot deleted a comment from 224148793 Jun 23, 2020
@jeecgboot jeecgboot deleted a comment from javaAjun Jun 23, 2020
@zhangdaiscott

This comment has been minimized.

@zhangdaiscott
Copy link
Member

zhangdaiscott commented Jun 29, 2020

新方案

删除@jeecg/antd-online-beta220,换成@jeecg/antd-online-220-mini
online的依赖从5M减少至1.3M

1、安装新依赖
     yarn add @jeecg/antd-online-220-mini

2、修改引用
     src/main.js
 
     require('@jeecg/antd-online-220-mini')
     require('@jeecg/antd-online-220-mini/dist/OnlineForm.css')

3、修改util引用
     src/utils/util.js

     import onlineCommons from '@jeecg/antd-online-beta220-mini'


详细参考此链接: https://www.npmjs.com/package/@jeecg/antd-online-beta220-mini

@zd551317
Copy link

zd551317 commented Jul 2, 2020

换成@ jeecg / antd-online-220-mini bulid报错了

@zd551317
Copy link

zd551317 commented Jul 2, 2020

新方案

删除@ jeecg / antd-online-beta220,换成@ jeecg / antd-online-220-mini
online的依赖从5M减少至1.3M
详细参考此链接:https : //www.npmjs.com/package/@jeecg/antd-online-beta220-mini

换成@ jeecg / antd-online-220-mini bulid报错 404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@jeecg%2fantd-online-220-mini - Not found

@zhangdaiscott
Copy link
Member

zhangdaiscott commented Jul 2, 2020

你安装依赖了?
yarn install

重新补充了操作步骤,看四楼

@zd551317
Copy link

zd551317 commented Jul 2, 2020

你安装依赖了?
yarn install

重新补充了操作步骤,看四楼

npm i @jeecg/antd-online-beta220-mini执行太慢了,依赖加载不到本地

@chongyangwang
Copy link

版本号:
2.2.0

问题描述:

前端打包js文件太大
image

根据此issue解决方法跟进 分别尝试楼上两种解决方案

  1. 本地直接删除依赖 "@jeecg/antd-online-beta220": "^1.0.1" 会导致富文本编辑功能失效

  2. yarn add @jeecg/antd-online-220-mini
    image

求教

@zhangdaiscott
Copy link
Member

是这样的,就是因为富文本太大所以去掉了

@chongyangwang
Copy link

  1. 第一种方案
    官方的意思是 只在上线的时候把 @jeecg/antd-online-beta220": "^1.0.1 这个包删掉? 本地开发依然留着? 如果删掉 部署到线上有问题怎么办?

  2. 第二种方案 @jeecg/antd-online-220-mini 的依赖库始终装不上 感觉这个包根本不存在吧?

@veranew
Copy link

veranew commented Sep 28, 2020

  1. 第一种方案
    官方的意思是 只在上线的时候把 @jeecg/antd-online-beta220": "^1.0.1 这个包删掉? 本地开发依然留着? 如果删掉 部署到线上有问题怎么办?
  2. 第二种方案 @jeecg/antd-online-220-mini 的依赖库始终装不上 感觉这个包根本不存在吧?

我也一直装不上,有什么解决方法吗

@rjliulei
Copy link

rjliulei commented Nov 4, 2020

用最新的版本,体积是小了,可还是慢。。也得接近1M。。。

@zhangdaiscott
Copy link
Member

1M已经最大努力了

@devinRex
Copy link

是否考虑提供用url的形式引入呢,通过cdn和浏览器强缓存去做缓存,chunk-vendor做持久化缓存还挺困难的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants