Table of Contents

Build scripts and cleanup

A small set of npm scripts that take Baseline's dev and build commands from "works on my machine" to predictable across platforms. Three helpers do the work: rimraf for cleanup, npm-run-all for sequencing, and cross-env for portable env vars.


Prerequisites

  • Baseline installed; package.json is ESM ("type": "module").
  • package.json with "type": "module" and scripts (start, build).
  • Install dev dependencies: npm install rimraf npm-run-all cross-env.

Install helper packages:

npm install rimraf npm-run-all cross-env

Add scripts to package.json

{
	"scripts": {
		"start": "npm-run-all clean dev",
		"clean": "rimraf dist/",
		"dev": "eleventy --serve",
		"build:eleventy": "cross-env ELEVENTY_ENV=production eleventy",
		"build": "npm-run-all clean build:*",
		"dryrun": "eleventy --dryrun"
	}
}

Run local dev with clean output:

npm start

Runs clean (removes dist/), then the dev server.


Run a production build:

npm run build

Runs clean, then build:eleventy with ELEVENTY_ENV=production.


Optional: dry run

npm run dryrun

Inspect what would be built without writing files.


Gate noindex for preview deploys

Preview and staging environments should not show up in search results. Set a PREVIEW (or similar) env flag in those environments and read it from data or computed data to flip noindex on. See deployment checks.


Notes

  • rimraf dist/ keeps output clean across platforms; adjust the path if you change dir.output.
  • npm-run-all sequences clean → dev/build; keep clean first so stale artefacts don't leak into builds.
  • cross-env sets ELEVENTY_ENV=production portably.

See also