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.

Production-Oriented Build Script
{
  "scripts": {
    "build:css": "sass --no-source-map --style=compressed src/scss/main.scss public/css/main.css",
    "build": "npm run build:css"
  }
}
💡 The example defines a CSS build command and invokes it through a higher-level build script. In a real application, the top-level build command should also run the framework's JavaScript bundler or other required build stages. Choose source-map settings based on your debugging and deployment needs. Ensure the output directory exists and that generated CSS is included in the deployed artifacts.
Knowledge Check

Why should a CI pipeline compile Sass before deploying an application?