Production Builds, Source Maps, and CI Validation
A production Sass build should be deterministic, reproducible, and integrated into the application's deployment process. Use the package lockfile to keep compiler versions consistent across developer machines and CI.
Source maps can connect compiled CSS to original SCSS during development and debugging. Depending on the deployment strategy, production source maps may be disabled or handled separately to avoid exposing source information unintentionally.
CI validation can include compilation, style linting, unit tests for any Sass tooling, and checks on generated asset sizes. Sass compilation failures should stop the build instead of allowing an application to deploy with missing or stale CSS.
Do not rely on local watcher processes as a production deployment strategy. Build the assets through a defined, repeatable command.
{
"scripts": {
"build:css": "sass --no-source-map --style=compressed src/scss/main.scss public/css/main.css",
"build": "npm run build:css"
}
}Why should a CI pipeline compile Sass before deploying an application?