简体   繁体   English

加速 ViteJs 开发模式。 视图 3

[英]Speed Up ViteJs dev-mode. Vue 3

Can someone help me speed up my ViteJs Server a bit?有人可以帮我加快 ViteJs 服务器的速度吗?

The problem is that in development mode the server is mega slow.问题是在开发模式下服务器速度非常慢。 I start the server, then start the page in the browser and wait 3-6 minutes for the page to load, Initially, ViteJs downloads a few kilobytes of resources.我启动服务器,然后在浏览器中启动页面并等待 3-6 分钟以加载页面,最初,ViteJs 下载了几千字节的资源。 then the request is in the "pending" state for 2-3 minutes.然后请求在“待处理”state 中持续 2-3 分钟。

Then the loading of all resources starts every time.然后每次都开始加载所有资源。 Although I also specified in the config that all css should be local.虽然我还在配置中指定所有 css 都应该是本地的。

Page reloading is also very slow.页面重新加载也很慢。

I start the project like this:我像这样开始这个项目:

vite

Here is my config:这是我的配置:

import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import {resolve} from 'path'

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      "@": resolve(__dirname, "./src"),
    },
  },
  publicDir: 'public',
  server: {
    port: 8080,
    watch: {
      usePolling: true,
      ignored: ['!**/bundle/**', '!**/lib/**']
    }
  },
  css: {
    modules: {
      scopeBehaviour: "local"
    }
  },
  preview: {
    port: 8080,
  }
})

Wow, the problem is in WSL2, Just tried, for the sake of interest.哇,问题出在 WSL2 中,为了感兴趣,刚刚尝试过。 to start vite from Windows.从 Windows 启动 vite。 Start page loaded in 1 second! 1 秒内加载起始页! I think I solved my problem myself!我想我自己解决了我的问题! Thanks!谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM