Skip to content

Consolidate into the canonical Node.js + Vite multipage (MPA) reference #16

@chriscalo

Description

@chriscalo

Goal

Make this repo the single canonical reference for a Node.js + Vite + multipage (MPA) app architecture, by migrating the best patterns from the sibling Vite repos into it and then retiring them.

This repo is the keeper because it has the most traction (20★, 8 forks) and already demonstrates true multipage — multiple HTML entry points at nested paths (index.html, foo/index.html, foo/bar/index.html). What it lacks is the Node.js tier and modern Vite config. We pull those in here.

Rename: this repo will be renamed from vite-multipage to vite-vue-mpa (the clearer name). GitHub preserves stars/forks on rename and redirects the old URL. The name is currently held by the repo we're retiring, so it gets freed first (see Retirement plan).

What to pull in (and from where)

Each item below is a decision, not an open question — migrate all of it.

From vite-vue-mpa (the Node + glob-MPA architecture)

  • Express server that mounts the UI as middlewareserver/index.js: server.use(uiServer), one Node server serves every page. This is the missing Node tier.
  • Glob-based MPA entry discovery — replace the hand-maintained entryPoints("index.html", "foo/index.html", …) list in the current vite.config.js with globbySync("pages/**/*.html")rollupOptions.input. Adding a page becomes "add an HTML file," no config edit.
  • appType: "mpa" in the Vite config.
  • Workspace monorepo splitcommon (isomorphic utils: html.js, http.js, module.js, file.js, listen()), server (Node), ui (Vite). Adopt the workspaces: ["common", "server", "ui"] layout.
  • htmlIncludes() Vite plugin and the listen() helper from common.

From vite-vue3-express-starter (the API tier)

  • Separate API middleware tier — mount an api/ workspace alongside the UI: server.use(uiMiddleware()); server.use(apiMiddleware()). Document the full stack (static pages + JSON API) in one server.
  • Do NOT carry its crufty deps — leave behind ramda, @repeaterjs/repeater, caller, hot-esm, 2-thenable. Migrate the pattern, not the dependency bloat.

Keep from this repo (vite-multipage)

  • The nested multipage pages — port them into the new ui/pages/ layout so the glob discovery has real nested entries to prove the MPA claim.
  • Sass support — preserve the style/style.scss setup.
  • ~ alias to project root.

Gaps to fix here

  • No Node server todaystart just runs http-server dist. Replace with the Express server above.
  • Vite 2 (beta) → upgrade to current Vite. Bump vite, @vitejs/plugin-vue, vue to current majors.
  • No workspaces — restructure into the common/server/ui monorepo.
  • README — rewrite to document the consolidated architecture (see below).

Target architecture (end state)

vite-multipage/
├── common/        # isomorphic utils (listen, htmlIncludes, http, module, file)
├── server/        # Express entry, mounts ui + api middleware
├── api/           # JSON API middleware tier
├── ui/            # Vite app
│   ├── pages/     # *.html entry points (auto-discovered → MPA)
│   ├── components/
│   ├── style/     # Sass
│   └── vite.config.js   # appType: "mpa", glob entry points, ~ alias
└── package.json   # workspaces: common, server, api, ui

README must explain the three load-bearing mechanisms:

  1. MPA entry discoveryglobbySync("pages/**/*.html")rollupOptions.input; add a page = add an HTML file.
  2. Node + Vite integration — Express imports the ui (and api) package as middleware; one server serves all pages and the API.
  3. Workspace splitcommon (isomorphic), server (Node), api (Node), ui (Vite).

Retirement plan (after migration verified)

  • Retire vite-vue-mpa once its server/glob-config/workspace patterns are confirmed working here. This also frees the vite-vue-mpa name.
  • Rename this repo vite-multipagevite-vue-mpa once the name is freed. (Do this after the retirement above; GitHub keeps stars/forks and redirects the old URL.)
  • Retire vite-vue3-express-starter once its API-tier pattern is ported.
  • Add a redirect note in both retired repos' READMEs pointing here as the canonical reference.
  • Leave vite-plugin-no-fallback untouched — it's a separate library, not an app.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions