meeko preview
Runs meeko build output in its real runtime (Node, Bun, Deno, wrangler dev or a file server) to test it before deployment.
meeko preview starts the production build with its adapter's runtime to check that what you will deploy works: it compiles nothing, so first run meeko build with the same adapter.
| Adapter | What it runs |
|---|---|
node |
The same server as meeko start, in this process. |
bun |
bun .meeko/output/bun/index.js, as a child process. |
deno |
deno run -A .meeko/output/deno/main.js, as a child process. |
cloudflare |
wrangler dev --config .meeko/output/cloudflare/wrangler.jsonc, the Worker in workerd with local bindings. |
static |
A small server responding like static hosting, with the CSP and server headers. |
Usage#
meeko build --adapter static
meeko preview --adapter statichttp://localhost:4173Type#
meeko preview [directorio] [--adapter <node|cloudflare|bun|deno|static>]Options#
| Option | Type | Default | Description |
|---|---|---|---|
[directorio] |
path | . |
Project root. |
--adapter <nombre> or --adapter=<nombre> |
node | bun | deno | cloudflare | static |
server.adapter, or node |
Which build to run. Must match the last meeko build. |
MEEKO_PORT (or PORT), MEEKO_HOST |
number, text | 127.0.0.1:4173 |
Server address. With cloudflare, passed to wrangler dev as --port and --ip. |
MEEKO_PUBLIC_ORIGIN and other variables |
The same as meeko start; the project's .env is read before startup and child processes inherit the environment. |
Result#
- Node and
staticprint the URL and serve in this process untilCtrl+C. As withmeeko start, loopback and0.0.0.0are displayed ashttp://localhost:4173and, with0.0.0.0or::,Red:lines follow with network addresses. Bun and Deno outputs print the same; Deno only lists the network with--allow-sys=networkInterfaces, included in-A. - Bun, Deno and Cloudflare inherit the child process's console, which writes its own output;
meeko previewforwardsSIGINTandSIGTERMto it and exits with the child's exit code. staticserves the requested file, the folder'sindex.htmlor404.htmlwith status404(orNot Foundif the build has no404.html, becauseapp/error.meekois missing), without exposing_headersor_meeko/, and appliescontentSecurityPolicyandheadersas hosting would withheaderFiles. Only acceptsGETandHEAD(another method gives405withAllow: GET, HEAD) and everything carriescache-control: no-cache.
Examples#
A static site before uploading#
meeko build --adapter static
MEEKO_PORT=5000 meeko preview --adapter staticcurl -sI http://127.0.0.1:5000/
# HTTP/1.1 200 OK
# content-type: text/html; charset=utf-8
# cache-control: no-cache
curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:5000/no-existe
# 404Bun or Deno#
meeko build --adapter bun
meeko preview --adapter bunThe build already contains all dependencies: what works here works by copying only .meeko/output/bun/ to the server. With Deno, preview grants all permissions (-A); in production, --allow-net, --allow-env and --allow-read for the folder suffice.
Cloudflare Workers locally#
pnpm add -D wrangler
meeko build --adapter cloudflare
MEEKO_PORT=8787 meeko preview --adapter cloudflarepreview uses the application's Wrangler or, if absent, the one from the Meeko installation.
The configured adapter#
With server: { adapter: "deno" } in meeko.config.ts, neither command needs --adapter:
meeko build
meeko previewCommon mistakes#
Preview a different adapter from the one built#
meeko build --adapter static
meeko previewWithout --adapter, preview takes the configured adapter (default node) and looks for another build: No hay build de producción en …\.meeko\output\node\index.mjs; ejecuta meeko build. For other adapters the message names their file, such as No hay build de producción en …\.meeko\output\deno\main.js; ejecuta meeko build --adapter deno or No hay build estático en …\.meeko\output\static; ejecuta meeko build --adapter static.
meeko build --adapter static
meeko preview --adapter staticCloudflare without Wrangler#
meeko build --adapter cloudflare
meeko preview --adapter cloudflareIf neither the application nor Meeko finds Wrangler: Wrangler no está instalado; añádelo con pnpm add -D wrangler para previsualizar el build de cloudflare.
pnpm add -D wrangler
meeko preview --adapter cloudflare--adapter without a name#
meeko preview --adapterFalta el nombre del adaptador en --adapter de preview, with usage information and exit code 1. An unknown name gives Adaptador desconocido: …; usa node, cloudflare, deno, bun o static.
meeko preview --adapter bunNotes#
- For testing, not production. With Node,
previewandstartare the same server; withstatic, thepreviewserver only imitates hosting and must not be exposed to the Internet. With Deno,-Agrants more permissions than required. - Runtimes.
bunanddenomust be inPATH. If the executable is missing, the error isBun no está instalado o no está en el PATH; instálalo desde https://bun.sh para previsualizar el build de bun(or the Deno equivalent). A version manager with shims, such asmiseorasdf, may intercept the command and display its own error. - Windows and POSIX. The child process launches without its own window on Windows, using the parent's console, and receives forwarded
SIGINTandSIGTERM. If the child terminates due to a signal,previewexits with code1. - Sessions. With Node, Bun and Deno,
previewruns in production mode: it needsMEEKO_REDIS_URLorsessionsinserver/runtime.ts, likemeeko start. - CSP.
previewappliesserver.contentSecurityPolicyandserver.headersjust as production does (withstaticsince1.3; with server adapters since1.7). Check here that CSP does not block anything before deployment.