vbenjs / vue-vben-admin

A modern vue admin panel built with Vue3, Shadcn UI, Vite, TypeScript, and Monorepo. It's fast!
https://www.vben.pro
MIT License
25.2k stars 6.87k forks source link

vite2的版本的服务比较慢,导致首次加载页面时间太长,建议升级vite到3的版本 #2160

Closed yeyuliang2015 closed 1 year ago

yeyuliang2015 commented 2 years ago

vite2的版本的服务比较慢,导致首次加载页面时间太长,建议升级vite到3的版本

yeyuliang2015 commented 2 years ago

升级后加载main.ts不会再卡住pending了

M69W commented 2 years ago

提 PR?

iconFehu commented 2 years ago

PR早提了 https://github.com/vbenjs/vue-vben-admin/pull/2083/commits/f44183e77e8c8f00a21fe4697485c4b60595970e

iconFehu commented 2 years ago

2083

image

yeyuliang2015 commented 2 years ago

提 PR?

还需要再提一遍么?

iconFehu commented 2 years ago

一个月了都,pr还没通过呢

yeyuliang2015 commented 2 years ago

@M69W

一个月了都,pr还没通过呢

这个有提过PR了

KongYoutao commented 2 years ago

vite2.0升级3.0需要注意什么吗

iconFehu commented 2 years ago

image https://cn.vitejs.dev/guide/migration.html

cnzdq commented 2 years ago

@iconFehu 改成vite 3还是老样子,main.ts 需要 30s 等待,能看到页面需要 50s,你们解决了吗

iconFehu commented 2 years ago

@cnzdq image 测试了下 页面加载完大概5秒钟

nguyenhan-se commented 2 years ago

@iconFehu hi, i have a problem when i upgrade vite 3 image Can u support me?

iconFehu commented 2 years ago

image @nguyenhan-se like this. You can check vite official website. https://vitejs.dev/guide/migration.html#config-options-changes https://github.com/vbenjs/vue-vben-admin/commit/f44183e77e8c8f00a21fe4697485c4b60595970e image image

nguyenhan-se commented 2 years ago

@iconFehu i cloned new vben project and apply like https://github.com/vbenjs/vue-vben-admin/commit/f44183e77e8c8f00a21fe4697485c4b60595970e but it's not working for me

nguyenhan-se commented 2 years ago

@iconFehu maybe i found the problem, the reason is "vite version 3.1.0"

iconFehu commented 2 years ago

@nguyenhan-se vite-plugin-theme v0.8.6 and vite v3.1.0 may not be compatible

WangShayne commented 2 years ago

@nguyenhan-se use vite 3.0.2

cnzdq commented 2 years ago

image

@iconFehu 我下了你的项目跑,虽然快了不少。但还是需要20s,不明白哪里不一样。你的是首次打开页面时的加载时间吗,就是从 pnpm dev 运行后第一次打开页面。首次加载完成之后,后面再刷新就很快了。我部署到云服务,不开启 gzip情况也是 15s,开启 gzip 后会快很多,大概3s

haozileung commented 2 years ago

@iconFehu maybe i found the problem, the reason is "vite version 3.1.0"

More precisely, It's not working since vite 3.1.0-beta.1.

See https://github.com/vbenjs/vite-plugin-theme/issues/27

yeyuliang2015 commented 2 years ago

@iconFehu 升级到3.0.9版本打包后,页面出现空白现象,无法访问。

dh336699 commented 2 years ago

Thanks four your suggestion, it has been fixed. Then when I first run yarn serve, the dashboard page spent 25s to load, it's still slow

passioncsu commented 2 years ago

额...满怀期待升级了一下 但是特意加载对比了, 好像没什么明显的提升....

ma-lihui commented 2 years ago

额...满怀期待升级了一下 但是特意加载对比了, 好像没什么明显的提升....

我升级后发现也依然很慢,后来发现是这个插件build/vite/plugin/styleImport.ts按需加载antd的样式非常耗时,作者之前做了优化,只在生产环境启用。后来不知道为啥又注释了。可以还原这两段代码试试 image image

mamba-in commented 2 years ago

更新后比之前快了30多秒,现在首加载16s左右,虽然还是有点长,确实比之前快多了

yeyuliang2015 @.***> 于2022年8月16日周二 11:10写道:

@M69W https://github.com/M69W

一个月了都,pr还没通过呢

这个有提过PR了

— Reply to this email directly, view it on GitHub https://github.com/vbenjs/vue-vben-admin/issues/2160#issuecomment-1216092817, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFBXGICUGWKTDHKQ4EUP2KDVZMBDZANCNFSM56GPPNPQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

yeyuchen198 commented 2 years ago

怎么开gzip?是用服务器端比如nginx打开gzip设置吗?还是前端项目这边比如.env配置VITE_BUILD_COMPRESS为gzip?

qwerlp commented 2 years ago

升级过程中报错 COLOR_PLUGIN_OUTPUT_FILE_NAME is not defined请问这个怎么解决vite-plugin-theme

fanzihui commented 2 years ago

什么时候可以升级到vite3 啊

M69W commented 2 years ago

什么时候可以升级到vite3 啊

https://github.com/vbenjs/vue-vben-admin/blob/next/package.json#L3

yeyuliang2015 commented 1 year ago

你们升级到vite3打包后,没有出现页面空白的现象吗? @iconFehu

qwerlp commented 1 year ago

升级过程中报错 COLOR_PLUGIN_OUTPUT_FILE_NAME is not defined请问这个怎么解决vite-plugin-theme 这里有解决方案 https://github.com/vbenjs/vite-plugin-theme/issues/27#issuecomment-1304458370

LuoHuacheng commented 1 year ago

额...满怀期待升级了一下 但是特意加载对比了, 好像没什么明显的提升....

我升级后发现也依然很慢,后来发现是这个插件build/vite/plugin/styleImport.ts按需加载antd的样式非常耗时,作者之前做了优化,只在生产环境启用。后来不知道为啥又注释了。可以还原这两段代码试试 image image

这里注释的内容放在 build/vite/plugin/theme 里面的 antdDarkThemePlugin 方法 preloadFiles 参数中去了,我把vite升级到最新的4.1.4之后按照这个 issue添加全局变量后切换暗黑模式有问题,把注释的这两个地方还原然后把 preloadFiles 去掉了,可以正常运行。

houyaowei commented 1 year ago

@LuoHuacheng 在vite@4版本打包后能正常运行么?我这边打包后html文件中没有注入js文件

houyaowei commented 1 year ago

所以只能将到3.2.5版本

zhunnyWang commented 1 year ago

vite-plugin-theme插件带来的问题可以这么改: 带来次变化的更新为https://github.com/vitejs/vite/pull/9848%E3%80%82 此更新自动为未优化的node_modules 导入加入hash值,因为该插件的tranform中的路径匹配方法失效。匹配不到正确路径,自然目标文件得不到更改,变量赋初始值就没办法生效。 最简单的改法,找的vite-plugin-theme打包后的transform方法,替换原有的路径匹配方法,endsWith替换为includes: if (nid === CLIENT_PUBLIC_ABSOLUTEPATH || nid.includes(path6) || nid.includes(path6.replace(///gi, "")))

huhyge commented 1 year ago

你们升级到vite3打包后,没有出现页面空白的现象吗? @iconFehu

我在升级成vite3.0.x打包后也出现了同样的问题,请问您解决了嘛如何解决的

houyaowei commented 1 year ago

你们升级到vite3打包后,没有出现页面空白的现象吗? @iconFehu

我在升级成vite3.0.x打包后也出现了同样的问题,请问您解决了嘛如何解决的

我的是一个插件导致的,把插件去掉就可以了

XiongAmao commented 1 year ago

@houyaowei Hello,请教一下你们是去掉哪个插件解决白屏问题的?