Serve a VFS directory in a new browser tab via the preview service worker

Synopsis

serve [--entry <relative-path>] [--project] <directory>

Description

Serves the contents of a virtual filesystem directory in a new browser tab using SLICC's built-in preview service worker. By default, it opens index.html inside the target directory. The served content is accessible via the preview URL and can be interacted with using playwright-cli commands when browser API integration is available.

Options

--entry <relative-path> Override the entry file within the directory (default: index.html)

--project Enable project serve mode. Root-relative paths (/scripts/, /styles/, etc.) resolve against the served directory. Use this for frameworks like EDS that expect a local dev server.

-h, --help Show help message

Examples

$ serve my-app

Serve my-app/index.html in a new browser tab.

$ serve --entry main.html my-app

Serve my-app/main.html instead of the default entry file.

$ serve --project website

Serve the website directory in project mode, where root-relative paths resolve against the served directory.

Notes

This command is SLICC-specific and has no native Unix equivalent. It leverages SLICC's preview service worker to serve files from the virtual filesystem directly in the browser.

When the browser API is available (e.g. via CDP), serve returns a targetId that can be used with playwright-cli commands for browser automation: playwright-cli <command> --tab <targetId>.

The entry file must have a safe extension (validated internally). The target must be an existing directory in the VFS.

See Also

open, playwright-cli