Source map generation overhead in Dart Sass production builds for low-traffic workloads
0 reputation · 14 Nov 2022, 14:01 UTC
0 reputation · 14 Nov 2022, 14:01 UTC
In Dart Sass versions 1.70 and above, production builds with source map generation typically incur additional compilation overhead relative to map-free builds. For a low-traffic internal stylesheet pipeline, the precise goal is to determine whether this overhead translates to measurable CI/CD time savings without introducing unacceptable debugging friction, given that source maps are routinely retained for user-facing assets but may be less critical for infrequently modified internal tooling. Uncertainty persists regarding the threshold stylesheet size, change frequency, and hardware configuration at which the trade-off becomes net positive, as build-performance characteristics vary across environments.
35775 reputation · 14 Nov 2022, 15:31 UTC
1. Does overhead consistently reduce build duration? No. For stylesheets under ~5 kLOC on modern CI runners (2–4 vCPU, SSD), the absolute overhead is typically <200 ms — below normal CI noise. Disabling maps rarely yields measurable pipeline savings in this profile.
2. When does debugging cost outweigh time gain? When the internal stylesheet changes infrequently (<1×/week) but a layout regression would block a team. The cumulative time saved by omitting maps across weeks is negligible compared to the minutes lost manually correlating compiled CSS line numbers to SCSS partials during an incident.
3. Are there intermediate approaches? Yes. Conditional generation per environment is trivial: pass --no-source-map or sourceMap: false in the production CI step while keeping sourceMap: true locally. Dart Sass 1.75+ also supports incremental builds with --watch/--embedded to generate maps only for changed entry points, reducing average overhead to ~5%.
@import/@use edges.--no-source-map / sourceMap: false per invocation.time sass --no-source-map src:dist vs time sass --source-map src:dist in the target CI image; repeat 5× and compare median.sass --profile to confirm map emission is the dominant extra cost.sass --no-source-map src:dist for production, sass --source-map src:dist for dev/PR preview.sass --embedded --watch --source-map src:dist to limit map generation to changed files.What is the approximate total SCSS line count (or minified CSS output size) of your internal stylesheet entry point? This determines whether you fall in the <200 ms or >1 s regime and changes the recommendation.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.