BlogGetting startedBuild

How to run Vendra locally and build it with Vite (HTML and React editions)

Open the HTML edition without a build, run the Vite dev server, rebuild dist/ after a change, and run, build and deploy the React 19 edition.

3 min readPerforks

The commands that run Vendra: install, the Vite dev server, the build and the tests

You do not need a build to use Vendra. You need one to change its source. This article covers both, for the HTML edition and the React edition.

Use the HTML edition as it is

Every page in dist/ is plain HTML that links one stylesheet and one script with relative paths, so the folder works from disk: double-click dist/index.html, or open dist/demos.html to see every storefront and page. A local web server is better, because some browsers restrict what a page opened from the file system may do; any static server will do.

To go live, upload the contents of dist/ to your host. The server-config/ folder has an apache.htaccess and an nginx.conf with the security headers and caching rules the pages expect.

Requirements for a build

  • Node.js 20 or newer.
  • For npm test and npm run responsive, a Chromium for Playwright: run npx playwright install chromium once.

Run and build the HTML edition

  1. Open a terminal in the vendra-v1.0.0 folder and run npm install.
  2. npm run dev starts the Vite development server with live reload and prints its address. Edit anything in src/ and the page refreshes.
  3. npm run build writes dist/: the pages, vendra.min.css, vendra.rtl.min.css and vendra.min.js, with a readable twin of each stylesheet and script. The build also adds a ?v= query to every asset link, so a new upload is never served stale, and a Content Security Policy meta tag with the hashes of the inline scripts.
  4. npm test opens every page in a real browser and runs the shopping flows; npm run responsive checks every page for horizontal overflow at five widths; npm run preview serves the built folder.
npm install
npm run dev        # development server with live reload
npm run build      # writes dist/
npm test           # every page loads without errors, plus the shopping flows
npm run responsive # overflow check at five widths

Two more scripts exist: npm run fonts regenerates the self-hosted font files and fonts.css from the installed Fontsource packages (only needed when you add a pack), and npm run placeholders writes a neutral placeholder image for every image a built page references that does not exist yet, which is handy after you add products before their photos arrive.

Run and build the React edition

The React edition lives in react/. It is a React 19 single-page app with React Router 7, and it imports the engine straight from ../src/js and Bootstrap from the parent's node_modules, so the parent must be installed first.

  1. In the parent folder: npm install (if not done already).
  2. cd react, then npm install.
  3. npm run dev serves the app on http://localhost:5175.
  4. npm run build writes static files to react/dist; npm run preview serves that build on http://localhost:4175; npm test builds, serves and checks every route and the shopping flows.

Every page answers both /name and /name.html, so links copied from the HTML edition keep working.

Deploying the React build

A single-page app needs the server to send index.html for paths it does not know. On nginx that is try_files $uri /index.html;; on Netlify a _redirects rule /* /index.html 200. To serve the app from a sub-folder, set base in react/vite.config.js or pass it on the command line, for example npx vite build --base /react/, which is how the live demo is built.

Keeping the two editions in step

The page components in react/src/pages are generated from the built HTML pages. After a change in the Handlebars source, rebuild the HTML edition and run npm run generate in react/; it rewrites the pages, the overlays, the route table and the catalogue. If you edit the generated components by hand instead, stop regenerating them, or keep your changes in separate components.

If a build stops with an error, see styles, images or scripts do not load, or the build fails.