How to omit sourcemaps in Angular-CLI 6+

As an alternative, open your package.json file.

Modify "test":"ng test" to "test":"ng test --source-map=false" or to "test":"ng test --sourceMap=false" for your angular CLI v6.x

Please note that it is --source-map and --sourceMap and not --source-maps which can be a usual mistake.


You can also add sourceMap: false into the configuration of angular.json as shown below

enter image description here

I suppose they are false by default for production build when using Angular 6+ with cli.


Use --source-map . It takes default value true. So following command will not create sourcemaps:

ng build --source-map=false

Similarly --prod avoids creating sourcemaps by default but if you want to create then just use --source-map in the end to create sourcemaps.

Follow official Docs

Update:

For Angular cli 7 use below:

ng build --sourceMap=false

And if you want prod build with production config & bundling (thus don't want sourcemaps included in build folder) then use :

ng build --prod=true

Recent Official Docs