Vite Build Output
Generate deployable artifacts with the CLI:
bash
pnpm exec mokup build --dir mock --out .mokupbash
npm exec mokup build --dir mock --out .mokupbash
yarn mokup build --dir mock --out .mokupbash
bunx mokup build --dir mock --out .mokupOutput structure:
.mokup/
mokup.manifest.json
mokup.manifest.mjs
mokup.manifest.d.mts
mokup.bundle.mjs
mokup.bundle.d.ts
mokup.bundle.d.mts
mokup-handlers/ (optional)mokup.bundle.mjs is the easiest entry for Workers or custom runtimes.
Service Worker build
When you set mode: 'sw' in the Vite plugin, the service worker script is emitted during vite build (default /mokup-sw.js). The plugin also injects a registration snippet unless sw.register is false.
ts
import mokup from 'mokup/vite'
export default {
plugins: [
mokup({
entries: {
dir: 'mock',
prefix: '/api',
mode: 'sw',
sw: {
path: '/mokup-sw.js',
scope: '/',
},
},
}),
],
}This is ideal for static hosting because mock requests are handled in the browser. If you also ship the playground, set playground: { build: true } so vite build emits the Playground assets and /__mokup/routes. As an alternative, you can generate /__mokup/routes with mokup build or a small script and publish it alongside the site.
Notes:
sw.basePathcontrols which requests the SW intercepts. If omitted, it inherits the entryprefix.