search

Home  >  Q&A  >  body text

Angular application without annotations

Is there any configuration setting to remove these empty comments and spaces?

My build command is ng build --environment prod --progress false --target production and tsconfig is:

{
    "compileOnSave": false,
    "compilerOptions": {
        "alwaysStrict": true,
        "baseUrl": "/",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "forceConsistentCasingInFileNames": true,
        "lib": [ "es2015", "dom" ],
        "module": "es2015",
        "moduleResolution": "node",
        "newLine": "CRLF",
        "noFallthroughCasesInSwitch": true,
        "noImplicitAny": true,
        "noImplicitReturns": true,
        "noUnusedLocals": true,
        "noUnusedParameters": false,
        "outDir": "./dist/out-tsc",
        "removeComments": true,
        "skipDefaultLibCheck": true,
        "skipLibCheck": true,
        "strictNullChecks": true,
        "target": "es5",
        "typeRoots": [ "./node_modules/@types" ]
    }
}

@angular/cli:1.0.4

Node: 7.2.1

Operating system: win32 x64

@angle/common:4.1.3

Thanks.

P粉939473759P粉939473759409 days ago652

reply all(2)I'll reply

  • P粉978551081

    P粉9785510812023-11-11 09:54:44

    Each of these annotations is a ViewContainerRef that Angular uses to hold the position of an expression that can render the view.

    When you have a ngIf, if the expression evaluates to false, obviously Angular will not render the element, but once it becomes true, it will render the element, so how Any idea where to put it?

    Of course there are other expression evaluations and view template bindings, but ngIf is the easiest to understand

    This is where these comments come from.

    reply
    0
  • P粉994092873

    P粉9940928732023-11-11 09:17:16

    This is generated based on your Angular directives, tags, conditions (if, for...), so this space is required. If you remove it then it won't perform very well and all two way bindings will disappear. These spaces determine how your angular DOM will be rendered and bound to models and variables. Additionally, the annotation tracks where the new DOM element will be rendered (if conditional and otherwise).

    See this link for more information: https://github.com/angular/angular.js/issues/8722

    reply
    0
  • Cancelreply