Skip to content

Vite and Node.js: Running a Local Server

Bryan M Lecza edited this page Dec 7, 2023 · 14 revisions

Introduction

In order to build our frontend, we needed to see what our website looked like as we constructed it. In order to do this, we needed to run a local server which could host our website and show live edits. The tools we used for this were Node.js and Vite.

Node.js

Vite

Vite is a development tool that comes with a local development server for building applications.

Why Vite?

Vite, which is French for "fast", was built in order to deliver high speed server start up and updates.

Faster Start Up

When creating your own server, dependencies can often cause slow start up times, however Vite pre-bundles dependencies causing speeds to increase by a factor of ten to a hundred.

Faster Updates

In bundler-based projects, rebuilding the entire bundle can be time consuming, and the time increases as the the size of the web application increases. Vite, however, uses Hot Module Replacement (HMR). Hot Module Replacement allows modules of the page to update themselves without affecting the entire page. In addition, Vite uses HTTP headers in order to boost full page reload speeds.

Bryan Lecza