EnglishNederlandsFrançais Toggle theme

Eleventy Baseline

Start building your site, skip the recurring setup work.
Table of Contents

Baseline 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.

1) Install helper packages:

npm install rimraf npm-run-all cross-env

2) Add scripts to package.json.

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

3) Run local dev with clean output:

npm run start

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

4) Run a production build:

npm run build

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

5) Optional: dry run.

npm run dryrun

Inspect what would be built without writing files.

6) 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. The deployment URL checks tutorial covers the full URL and env story alongside it.

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.