English 中文(简体)
低温振动
原标题:Slow Vite startup

Recently I started a new project in React v18 which uses Vite v4.1.1 as a build tool. After installing a few libraries the initial load of the app (after running npm run dev) takes several minutes even though the Vite itself starts within a few seconds. After it, the HMR works fine and every change is reflected very fast. I noticed that some dependencies take 1-2 minutes to fetch (in the network tab).

https://i.stack.imgur.com/XsTM9.png”rel=“noreferer”> 表格

在这一情景下,一些排位从海滩上排出,但如果没有,反应路线、人工或反应频率可每负荷一个分钟。 在此,主要问题似乎是React app的主要档案,我更不理解。

Can someone explain why it takes so long and how to improve startup time? I saw that it can be related with pre bundling but on the recent project, I didn t have such poor perf.

我的发言:

      "@emotion/react": "^11.10.5",
      "@mantine/carousel": "^5.10.3",
      "@mantine/core": "^5.10.3",
      "@mantine/hooks": "^5.10.3",
      "@tanstack/react-query": "^4.24.4",
      "axios": "^0.27.2",
      "embla-carousel-react": "^7.0.9",
      "react": "^18.2.0",
      "react-dom": "^18.2.0",
      "react-router-dom": "^6.8.1",
      "tabler-icons-react": "^1.56.0"

And dev deps:

      "@types/react": "^18.0.27",
      "@types/react-dom": "^18.0.10",
      "@types/styled-components": "^5.1.26",
      "@typescript-eslint/eslint-plugin": "^5.34.0",
      "@typescript-eslint/parser": "^5.34.0",
      "@vitejs/plugin-react": "^3.0.1",
      "@vitejs/plugin-react-swc": "^3.1.0",
      "autoprefixer": "^10.4.13",
      "eslint": "^8.22.0",
      "eslint-config-airbnb": "^19.0.4",
      "eslint-config-airbnb-typescript": "^17.0.0",
      "eslint-config-prettier": "^8.5.0",
      "eslint-config-standard-with-typescript": "^22.0.0",
      "eslint-import-resolver-typescript": "^3.5.0",
      "eslint-plugin-import": "^2.26.0",
      "eslint-plugin-jsx-a11y": "^6.6.1",
      "eslint-plugin-prettier": "^4.2.1",
      "eslint-plugin-promise": "^6.0.0",
      "eslint-plugin-react": "^7.30.1",
      "eslint-plugin-react-hooks": "^4.6.0",
      "postcss": "^8.4.21",
      "prettier": "^2.7.1",
      "sass": "^1.58.0",
      "tailwindcss": "^3.2.6",
      "typescript": "^4.7.4",
      "vite": "^4.1.1",
      "vite-plugin-eslint": "^1.8.1"

Vite config文档

import { defineConfig } from  vite ;
import react from  @vitejs/plugin-react ;
import eslintPlugin from  vite-plugin-eslint ;

export default defineConfig({
   plugins: [react(), eslintPlugin()],
   server: {
      port: 3000,
      open: true
   }
});

我只想提一下在docs中关于依赖前消亡的简短说明,但这并没有涉及我的问题。 在Gite Hub也看到了一个问题,即Tailwind能够造成这一问题,但甚至在我安装了Tailwind之前,问题依然存在。 现在没有任何想法能够造成这种状态。

问题回答

我发现,在更新或改变依赖性之后,第4类和随后的发射速度略微慢(因为尚未优化)。 我有时有11秒。 然而,随后的运行速度要快得多,在第三轮发射时间。 难道这真是这样吗?

If you are on Windows and running Vite on a WSL (or GitBash) terminal, try Powershell! Some Windows settings and configs might impact the WSL performance accessing LAN





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签