5
votes

I updated Angular project from Angular 10 to 11x. Everything works normally, except for one warning on running project using ng serve (without any option in ng serve). The warning is:

Option "sourceMap" is deprecated: Use the "sourceMap" option in the browser builder instead.

The warning is not presented in ng build.

Here is how browser builder part in angular.json of the project looks like:

"builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/my-app",
            "index": "src/index.html",
            "sourceMap": true,
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": true,
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],

Something related has changed in Angular 11? How to remove this warning?

2
What is your "serve" section in angular.json?HTN
I actually tried the configuration you posted and I dont get the same warning. I don't think its relevantmisha130
@HTN, here is "serve" section in my angular.json: "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { "browserTarget": "my-app:build", "sourceMap": { "scripts": true, "styles": true, "vendor": true } }, "configurations": { "production": { "browserTarget": "easyproduction-web:build:production" } } },viking
I don't understand the question. The warning says: "Option "sourceMap" is deprecated". In your serve configuration you have "sourceMap": { "scripts": true, "styles": true, "vendor": true } }. What exactly is unclear with this warning?user15388024

2 Answers

5
votes

You need to remove sourceMap from serve --> options --> sourceMap, which is deprecated.

5
votes

I was confused by some of the answers, these options aren't really deprecated but should now be specified in the proper "build" section of angular.json, not "serve".