【问题标题】:Will angular remove typescript or html comment during the compilation process?编译过程中 Angular 会删除 typescript 或 html 注释吗?
【发布时间】:2022-10-16 19:00:32
【问题描述】:

Angular 编译 typescript 并使用 ng serve 命令将它们转换为 javascript。我的问题是,它是否默认删除 html 文件中的所有评论,打字稿。或者你有能力通过在文件中设置选项来做到这一点,比如angular.json

【问题讨论】:

    标签: javascript html angular typescript


    【解决方案1】:

    默认情况下,不删除 cmets。如果您想从 Html 文件中删除 cmets,您只需在生产模式下构建您的应用程序:ng build --prod

    如果要从 *.ts 文件中删除 cmets,则需要在 tsconfig.json 文件 (https://www.typescriptlang.org/tsconfig#removeComments) 中设置 removeComments,如下所示:

    {
        "compilerOptions": {
            "removeComments": true,
            ...
        },
        ...
    }
    

    【讨论】:

      猜你喜欢
      • 2014-01-21
      • 1970-01-01
      • 2011-07-23
      • 2012-09-27
      • 2011-11-11
      • 2012-06-20
      • 2016-03-05
      • 1970-01-01
      • 2012-04-04
      相关资源
      最近更新 更多