brrrty 0.0.10

Brrrty, a fast static site generator compatible with Eleventy (11ty) projects.
Documentation

Brrrty

Eleventy, but make it go brrr.

Brrrty is a fast, independent static site generator written in Rust that aims to build your existing 11ty site unchanged.

Three Rs, like "go brrr".

Brrrty exists because Eleventy is great. See NOTICE.

Status: early development. Not ready for real sites yet.

Install

In a Node project, from npm, with a prebuilt binary for macOS (arm64, x64) or Linux (arm64, x64; static, so Alpine works too):

npm install --save-dev brrrty

Then "build": "brrrty build" in your package.json scripts, or npx brrrty build. No Rust toolchain or install scripts are needed.

Anywhere Rust runs:

cargo install brrrty

Release binaries are also attached to each GitHub release.

brrrty serve

brrrty serve [--port 8080] [--host localhost] [--input DIR] [--output DIR] [--passthrough PATH] [--quiet] [--strict]

Builds the site, serves it at http://localhost:8080/, and rebuilds whenever a source file changes, as eleventy --serve does. Open pages update by themselves: an edit to the page's own template is patched in without a reload, a stylesheet edit swaps the stylesheet, and anything else reloads the page. Build errors print in the terminal and in the browser console. A page whose template has an error keeps the version last served, so a typo never turns the page you're editing into a 404, while the rest of the site goes on updating. A page that has never built is a 404 until it does.

  • --port: when it is taken, the next free port up to 10 above it is used, and the startup line says so.
  • --host: the address to listen on. The default only answers this machine; --host 0.0.0.0 lets other devices on your network in.
  • --output is kept up to date after every build, so it holds the site while you work and after you stop. It gets exactly what brrrty build would write: the pages that built, never the older copies kept for pages with errors. As with brrrty build, files it didn't write are left alone. The one removal: when a build writes a file where the folder holds a folder by that name, or a folder where it holds a file, the old one is replaced (brrrty build stops with an error there instead).
  • --quiet prints only the Server at line, errors and warnings.
  • --strict stops each build at its first error, and exits with status 1 if the first build has errors, as eleventy --serve does. With it, a build with an error is never served; the last one stays up.

Ctrl-C stops cleanly: a build already running finishes, the output folder holds the last good build, the port is released, and the exit status is 0. A second Ctrl-C quits at once. SIGTERM stops the same way and then ends by the signal.

While it runs, each build goes into <output>/.brrrty-serve/, which is removed when it stops. A leftover one from a session that was killed is removed by the next brrrty serve or brrrty build. A running session holds a lock on it: brrrty build into the same output folder leaves it alone and says so, and a second brrrty serve there refuses to start. It is never served. If the first build fails and no build ever fills the output folder, a folder the session created is removed when it stops.

Pages get a small script, /.brrrty/reload-client.js, so a site's own files at /.brrrty/reload-client.js, /.brrrty/morphdom.js and /.brrrty/live are hidden while serving.

Where it differs from eleventy --serve:

  • It listens on localhost only, unless you pass --host, and on that address answers only requests that name this machine (localhost, 127.0.0.1, [::1]), so another website can't reach it through a DNS trick.
  • It never serves a file outside the output folder: .. and its encoded forms get a 404, and so does a symlink that points outside. A malformed URL gets a 400.
  • A build with errors in some pages still serves the rest, and its pages that built are written to the output folder, as brrrty build writes them. eleventy --serve writes nothing from a build with an error, and exits when the first build has one (see --strict).
  • Any file under the input folder starts a rebuild, not only template, data and include files, and so does deleting one, so a deleted page disappears from what is served.