p5-server
FeaturesSketch Explorer
The Sketch Explorer is similar to Visual Studio Code's built-in Explorer, but the Sketch Explorer is organized around sketches instead of files. It supports both sketches that are included in HTML files, and JavaScript-only sketches (that don't have an HTML file). The extension finishes loading after VS Code starts so the P5 Server status item remains immediately available. The server and its browser-console relay still load only when a sketch is run.
Clicking on a sketch in the Sketch Explorer opens its JavaScript file in the Visual Studio Code editor. Integrated Web Server
The extension includes a local web server. This server reloads sketches when files are modified. It also serves JavaScript-only sketches in a way that the browser can play. Integrated BrowserThe Run Sketch command can open the sketch in an external web browser (such as Chrome, Safari, or Edge), or in VS Code's integrated browser. (The "P5-server: Browser" setting controls this.) The integrated route uses the current built-in browser when available and falls back to Simple Browser on compatible older builds. If the "P5-server > Explorer: Auto Run Sketch On Side" setting is enabled, clicking on a sketch in the Sketch Explorer also runs it next to the editor. This makes it easy to quickly browse a collection of sketches.
Browser DebuggingDebug P5 Sketch starts the server if necessary and launches VS Code's
browser debugger. Breakpoints, stepping, variables, the Debug Console, and the
usual debug controls work without creating a Integrated Console
When the "P5-server: Browser" setting is set to The console output pane automatically appears when a message is printed to it. This behavior can be changed via the "Console > Integrated Browser > Auto Show: Level" setting. High-volume output is batched to keep the editor responsive. Inline messages are coalesced and retain a bounded recent history. Turning off the Editor > Info Lens setting removes the extension's inlay hints and diagnostics; output-channel logging continues. Automatic Library IncludesIf a JavaScript-only sketch uses a class or function from one of the p5.js community libraries, or from my own library collection, that library is automatically included. In the screenshot below, the extension infers that the The explorer also detects that the file
Other Features
InstallationView the Visual Studio Code Marketplace extension page, and click the Install button. P5 Server requires Visual Studio Code 1.115 or newer. After installation, open Help: Get Started and select Get Started with P5 Server for an in-editor walkthrough. Step by StepStep-by-step installation and usage instructions are here. ConfigurationThe extension provides configuration settings to set the browser, and to hide various user interface elements. Follow these instructions to modify these settings.
LimitationsSee the p5-server documentation for limitations that also affect this extension. In particular:
Related ProjectsThe sketch-aware server is available as command-line tool at
p5-server. Install it via The command-line version can also be used to generate a static web site. This creates the HTML files that are necessary to run the sketch in a browser without a special server. The code to infer libraries from JavaScript-only sketches, and to generate HTML files based on this, is available as a separate package. https://code.osteele.com lists my other p5.js projects. These include tools, libraries, and examples and educational materials. DevelopmentFor information on developing and contributing to this extension, please see DEVELOPMENT.md. Keeping in TouchBug reports, suggestions, and other contributions are cheerfully accepted. Please use the Issues page of the GitHub repository. Acknowledgements
LicenseMIT by Oliver Steele |






