How to enable source maps in Angular

Enabling source maps allows you to debug production Angular applications by mapping minified code back to the original TypeScript source. As the creator of CoreUI with over 11 years of Angular development experience since 2014, I’ve debugged countless production issues using source maps. The most effective solution is to configure source maps in angular.json for different build configurations. This approach enables debugging without exposing unminified code to end users.

Configure source maps in angular.json for development and production builds.

// angular.json
{
  "projects": {
    "your-app": {
      "architect": {
        "build": {
          "configurations": {
            "development": {
              "sourceMap": true,
              "optimization": false
            },
            "production": {
              "sourceMap": {
                "scripts": true,
                "styles": true,
                "vendor": false,
                "hidden": true
              },
              "optimization": true
            }
          }
        }
      }
    }
  }
}
# Build with source maps for debugging
ng build --source-map

# Development build (source maps enabled by default)
ng build

# Production build with hidden source maps
ng build --configuration production

Source maps create .map files that browsers use to display original TypeScript code in DevTools. In development, source maps are enabled by default for easier debugging. For production, use hidden source maps which aren’t referenced in the bundle but can be uploaded to error tracking services. Setting vendor: false excludes third-party library maps to reduce build size.

Best Practice Note

This is the same source map configuration we use for CoreUI Angular projects. For production, use hidden source maps and upload them to error tracking services like Sentry rather than serving them publicly. This allows production debugging without exposing source code to end users or increasing bundle download size.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author

Subscribe to our newsletter
Get early information about new products, product updates and blog posts.
How to Hide Scrollbar with CSS
How to Hide Scrollbar with CSS

How to limit items in a .map loop in JavaScript
How to limit items in a .map loop in JavaScript

The Best Bootstrap Alternative for Developers in 2025
The Best Bootstrap Alternative for Developers in 2025

The Wacky World of JavaScript: Unraveling the Oddities
The Wacky World of JavaScript: Unraveling the Oddities

Answers by CoreUI Core Team