Recently, the company’s projects are getting bigger and bigger. It takes one or two minutes to start each time. In order to find the fish for a longer time, I decided to switch to Vite

Direct reference to Yamami’s gadgets:wp2vite

Even after you use it, you still find many minor problems:

1. Require cannot be used in vite when importing multiple files in a folder

Context (‘./modules’, true, ‘.js$’) import.meta. GlobEager (‘./modules/*.js’)

2. SVG cannot use the solution:

Github.com/anncwb/vite…

3. JSX cannot be used

Add lang=’ JSX ‘to script tag

4. Path cannot be used

NPM I path-browserify; Import path from ‘path-browserify’ import path from ‘path-browserify’

5.unexpected token < in JSON at postiion 0

I encountered this problem for a variety of reasons. ‘, can’t parse, just write it in a different way.

Completion: Generally speaking, it was smooth. It took more than 60 seconds to start before, but now it only takes 1s, and the hot loading is several times faster

This is vue2.6.x, and the problem with vue3.x should be similar