A lightweight Vite plugin providing local mock APIs during development, with HMR support for mock files. Version 1.0.3 (stable, last release unchanged from 1.0.1) is a TypeScript-based fork of vite-plugin-mock-server with zero dependencies. Supports ant-style path patterns, JSON bodies, custom handlers, and configurable delays. Differentiators: zero external dependencies beyond Vite, simple API using arrays of route definitions, and optional JSON shorthand via `jsonBody`.
npm install vite-plugin-mock-simpleVerified import paths — ran on the pinned version, not inferred.
Vite config with mockSimple plugin: three route examples – custom handler, JSON response, and delayed response.
Use either `handle` or `jsonBody` per route definition, not both.
Use consistent comma+space separation: 'GET, POST, DELETE'. Trim spaces around methods.
Always start pattern with `/` (e.g., `/api/**`).
Add `method: 'POST'` or `method: 'GET, POST'` if you need multiple methods.
Ensure package is in devDependencies: `npm i -D vite-plugin-mock-simple`. If type errors persist, add to tsconfig.json compilerOptions.types or skipLibCheck.
Use default import: `import mockSimple from 'vite-plugin-mock-simple'`.
Every route definition must include `pattern` and exactly one of `handle` or `jsonBody`. Example: `{ pattern: '/api/test', jsonBody: {} }`.