Skip to article frontmatterSkip to article content
tools = require('../js/tools'); tools.init()
Loading...

what is vite ?

are you tired of reloading the browser page after each and every single change in your sources ?

vite is what you’re looking for ...

with vite, you typically have your two windows side by side: an editor - say, vscode - and your browser
and you just need to save your input - be it .html, .css or .js - and the browser automatically picks up on your changes and re-renders the current code
is that cool or what ?

a local web server

no file:/// URL

for that to work, you can no longer open in your broswer a file URL like file:///Users/jeanmineur/the-webc-course/cv.html

how to open a file then ?

the way it’s going to work with vite is:

and that’s it
from then on, any change done in cv.html will automatically refresh in the browser

basic install

we’re going to use vite through a tool named npx; this tool will let us run vite without the need for any prior installation

however, we still need .. to install npx of course; fortunately it all boil down to installing node.js
just like a Python install comes with pip, node will come with npm and npx

installing node and npx

how to use it ?

with most of the activities / exercises contained in this course, you will just need to run (in the right folder of course)

npx vite

which as part of its display will show a line like

  ➜  Local:   http://localhost:5173/

and now, you know which port number to use

caveats

conclusion

there are additional features in vite in terms of vite build, but that’s totally optional

if you’re serious about web development, using vite in development mode is a lifechanging experience
totally worth the small amount of time required to get used to it ;)