A Vite plugin that serves as middleware for handling fallback to an index page when using HTML5 History API for multiple single-page applications. Version 0.0.1, early release with basic functionality. Differentiates from history-api-fallback by targeting Vite's dev server and supporting multiple SPA entries. Requires peer dependency vite ^2.6.4. Documentation is minimal; usage patterns may change in future versions.
npm install vite-plugin-history-api-fallbackVerified import paths — ran on the pinned version, not inferred.
Configures the plugin to rewrite requests for /app1 and /app2 to their respective index files, with a global fallback to /index.html.
Use a production-grade fallback middleware like connect-history-api-fallback for built output.
Use import historyApiFallback from 'vite-plugin-history-api-fallback' to be safe across versions.
Use regex patterns anchored at start, e.g., /^\/app1/.
Set 'index' to your actual fallback file, e.g., '/app/index.html'.
Run npm install vite-plugin-history-api-fallback and use import instead of require.
Use import historyApiFallback from 'vite-plugin-history-api-fallback' or import { historyApiFallback } from 'vite-plugin-history-api-fallback'.Add a rewrite entry for the route, e.g., { from: /^\/some/, to: '/index.html' }.