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.jsonis ESM ("type": "module"). package.jsonwith"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 changedir.output.npm-run-allsequences clean → dev/build; keepcleanfirst so stale artefacts don't leak into builds.cross-envsetsELEVENTY_ENV=productionportably.
See also
- Config export -
dir.output, and what else the forwarded config decides. - Deployment checks - the other environment variable the build scripts carry.
- Create the project - where these scripts get written for the first time.