liveBook · Manning

Vite

As explained in Web Component Development with Modern Libraries and Tooling

Vite is a frontend build tool and development server that supports modern JavaScript modules, TypeScript, and fast incremental updates.

Vite is a convenient development server and build tool for web-component projects. Its local HTTP server lets a page load ECMAScript modules instead of opening the page as a local file, which can trigger browser security errors. Vite also supports TypeScript. When you save a source file, hot module replacement updates the page without a full refresh, preserving page state. section 3.5

Run a web-component demo

A page can import a button component with a module script and render it as <wa-button>Click Me</wa-button>. Install Vite with npm install -D vite, add a dev script, then run npm run dev and open the local address Vite reports. The same setup can serve a vanilla sortable-table component or a Lit project. section 2.2 section 4.3 section 5.1

"build": "vite build", #1
"dev": "vite", #2
"preview": "vite preview", #3

These package.json scripts provide commands to start the server, build the app, and preview the build. section 3.5

For a production build, Vite bundles application code and dependencies, removes unused code through tree shaking, and can split code into chunks loaded on demand. It is a practical choice, not a web-component requirement: another HTTP server can serve the page, and FAST and wrec projects do not require Vite. section 3.5 section 7.2

How Web Component Development with Modern Libraries and Tooling covers it

How deep it goes
Gives installation steps, npm scripts, and build-feature explanations, but does not explain Vite internals.
Examples
Uses a Web Awesome button, a sortable table, and starter projects for Lit, FAST, and wrec.
What it assumes
Assumes Node.js is installed; shows how to initialize an npm project and install Vite.
What you can do after
Operate/configure it to serve a local web-component project and run build and preview commands.
How it connects
Connects ECMAScript modules, TypeScript, hot module replacement, tree shaking, and code splitting to web-component development.

Also explained in

Compare how 2 books explain Vite →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Component Development with Modern Libraries and Tooling. The section links point to the parts of the book it draws on.