Kho tháng 12/2025

Fri Dec 5 04:55:06 PM CET 2025

deno and vite, part 1

Suddenly wanted to look at javascript again (and not because of the react vulnerability). First step though is to go small(-ish). So forget react, let's just start a new server. Which seems to be vite in this case somehow.

Creating a new project is just

deno run -A npm:create-vite-extra --template deno-vanilla

which prepares everything and starting is just

cd vite-project
deno task dev

The project name will be asked during deno run. The --template can be dropped too and be chosen from a TUI-like list.

Not really sure how URL routing works yet, but any .html file at topdir shows up in the web browser's top URL as well. In dev mode, vite inserts

<script type="module" src="/@vite/client"></script>

which probably helps auto reload the page when the source file is changed. It should be in <head> node if it's there otherwise it's directly under <html>. That's 1000 lines or 179kb, no way to actually read it.

In the .html file, src attribute of <script> tag is rewritten. src is local path while of course the real path has to be URL. The rest seems standard typescript.

One interesting bit is the import statement from javascript apparently can load css as well. We don't even need separate html tag for that. Or importing an SVG to a variable. The variable apparently contains the SVG embedded in the URL (with data: "protocol").


Tác giả: pclouds | Liên kết tĩnh