I use web-pack before and wanted to change it to vite I copied all the file from the web-pack version to the vite version
when I issue yarn dev it work but we I build it and run the build with serve dist it give me this error on the browser and it won't render any thing
Asked
Active
Viewed 6,204 times
3
Revan99
- 396
- 2
- 5
- 11
-
Have you tried `npm isntall` again so all dependencies can be installed ? – Bao Huynh Lam Feb 14 '22 at 06:13
2 Answers
3
You need to use this config, (take a look at @vitejs/plugin-react which you probably need to install)
vite.config.js:
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
export default ({ mode }) => {
return defineConfig({
plugins: [
react(),
],
});
};
The thing is that vite does not import React by default into jsx components, so you need to do it manually in every component or use this plugin.
valerii15298
- 737
- 4
- 15
2
the problem was with a react library called react-custom-scrollbars
Revan99
- 396
- 2
- 5
- 11
-
I've got exactly the same issue with react-custom-scrollbars-2. It's quite strange that Vite doesn't show just errors in dev mode. – Anatolii Olshevskyi Apr 16 '22 at 19:41
