【问题标题】:Using ng-annotate with angular cli将 ng-annotate 与 Angular cli 一起使用
【发布时间】:2017-09-16 22:24:34
【问题描述】:

我有一个现有的 angular.js 应用程序,我正在使用 NgUpgrade 升级到 angular。我也在尝试使用 angular cli 作为构建系统。 ng serveng build 完美运行,但我在使用 ng build -prod 时遇到了问题。

对于原始应用程序,我使用 gulp 进行构建,作为中间步骤,我使用 ng-annotate 转换了输入文件。我很难让它与 angular cli 一起使用。

有没有办法将 ng-annotate 与 ng build -prod 集成?或者在缩小之前处理 angular.js 文件的任何其他方式?

【问题讨论】:

  • 您好,您的问题解决了吗?我会感兴趣的。谢谢
  • @Cyril 抱歉,我从未找到解决此问题的方法。
  • 我终于通过直接使用 Webpack 和 'ng-annotate-webpack-plugin' 解决了这个问题!
  • @Cyril 你能告诉我们你的 webpack 配置以及你是如何运行客户端服务器的吗?
  • 您是否弹出了 Angular CLI 配置?

标签: javascript angularjs angular angular-cli ng-upgrade


【解决方案1】:

我使用babel-plugin-angularjs-annotate 做到了这一点,它以永久的方式将注释添加到源文件中(因此,您只需要运行一次)。

我在this other SO post放了详细说明。

注意 Babel 不应该被添加到你的 Angular 项目中。相反,您创建了第二个项目,并在其中执行 Babel。 Babel 会从你指定的文件夹中读取文件,并在你指定的另一个文件夹中生成带注解的文件。

运行一次后,您可以忘记 ng-annotate。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-10
    • 1970-01-01
    • 2018-11-04
    • 2015-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多