2 comments

[ 2.9 ms ] story [ 22.4 ms ] thread
I came across this in desperation trying to get a Lit element to work in the browser. That requires "bare" Node module names on imports, something the Lit folks admit doesn't work any any browser! Good times. Also, Lit works in JS but is more elegant in TypeScript.

This Vite server handles both transparently with instant hot reloads in the browser as you change any files. You can <script src="someFile.ts"> and it just works. It also resolves bare module imports so you can suck in Node modules.

Finally, it has a "bundler" function to package it all into a final app when you're done w/ developing.

BTW, if you do try it, you can skip all of the scaffolding and init steps by just running two lines from your web app directory:

npm install vite

npx vite

This serves index.html from that folder by default on port 3000. Bare imports and TS transpiling are on by default.