tidemark is a small tool I maintain that turns Markdown into HTML you can paste straight into WeChat articles. There isn’t much code, but the build took 38 seconds in CI, and even a one-line theme tweak meant waiting over ten seconds locally. For a tool whose whole job is tweaking styles, that feedback loop is fatal.
Measure first
I didn’t reach for a new bundler. I put timestamps around each stage first:
time pnpm build --reporter=verbose
The result was humbling. Actual compilation took only 6 seconds. The rest went to two things: re-parsing the CSS for all 12 themes on every run, and bundling test snapshots into the output.
Three fixes
- Precompile the themes. Theme CSS is compiled to JSON before publishing, and at runtime it’s only read. That saved 19 seconds.
- Stop bundling what doesn’t belong. Snapshots and fixtures were removed from the build entry, and the output shrank by 70%.
- Incremental caching. The cache key is a hash of file contents, so unchanged themes are reused, and local hot reload dropped to around 300 milliseconds.
A small lesson
Looking back, the biggest win came from doing less rather than doing things faster. Most slow builds repeat work that never needed repeating. Next time a build feels slow, don’t swap tools yet. Look at the timestamps first.
CI now holds steady at about 4 seconds, and I can finally finish tweaking a theme before my coffee goes cold.