Menu

Post image 1
Post image 2
1 / 2
0

Vite predev/prebuild: chaining scripts without losing your mind

DEV Community: vite·Dk Usa·3 days ago
#XsyMjGwT
#dev#scripts#node#build#hash#steps
Reading 0:00
15s threshold

A project I'm working on needs 3 things to happen before dev/build: Hash legal content (license, terms) to detect changes. Split a huge GeoJSON file into per-region chunks. Generate static SEO landing pages from a metadata JSON. npm's pre- scripts hook into dev and build automatically. But chaining 3+ steps gets messy fast. ## What I tried first json { "scripts": { "predev": "node scripts/hash.js && node scripts/split.js && node scripts/gen.js", "prebuild": "node scripts/hash.js && node scripts/split.js && node scripts/gen.js", "dev": "vite", "build": "vite build" } } Works. Two problems: Duplication: predev and prebuild are identical. Add a 4th step and you change two places. Hard to debug: if step 2 fails, the error reaches you but the chain stops without context.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More