Vite
Up until now, we were doing fine with the VS Code Live Server. But since our applications will become more and more complex (depending on npm packages to give an example), we need a more advanced development server. This is where Vite comes in. There are a lot of advantages, the following is just a summary:
+Vite
Up until now, we were doing fine with the VS Code Live Server. But since our applications will become more and more complex (depending on npm packages to give an example), we need a more advanced development server. This is where Vite comes in. There are a lot of advantages, the following is just a summary:
Features
Dev server
Vite is a development server that has some special tricks up its sleeve to start it up fast, even when a lot of libraries need to be loaded first.
-HRM
-Vite has Hot Module Replacement (HRM) built in. This means that when you change a file, the browser will automatically reload the page. And again… does this fast.
+HMR
+Vite has Hot Module Replacement (HMR) built in. This means that when you change a file, the browser will automatically reload the page. And again… does this fast.
Production build
Vite can also build your application for production. It will bundle all your files into one or more files and minimizes it. It strips out all the comments and unused code. This makes your application smaller and faster.
Plugins
@@ -121,7 +121,7 @@Exploration
If you want to stop the dev server, you can enter Ctrl + C
in the terminal.
HMR
+HMR
Organize your desktop so that a browser and VS Code are side by side. Make sure that the Vite dev server is running. Now edit the style.css to give the page a red background. You will see that the background of the page turns red immediately —without doing a full page refresh.- When you open up your Developer Tools and inspect the head element, you will experience that only the style tag changes when you change the background color.
Build it
When you are done with your project, you can build it for production.