【问题标题】:Update CDN links in HTML更新 HTML 中的 CDN 链接
【发布时间】:2023-04-03 19:23:01
【问题描述】:

我在我的一个项目中使用AngularJS。除了核心 angular.js 文件之外,我的 HTML 中还列出了几个 AngularJS 组件,全部来自 Google Hosted Libraries

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular-touch.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular-route.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular-animate.js"></script>

AngularJS 的更新非常频繁,这很棒。不好的是在每次更新时手动编辑每个 URL 的版本号。

有没有办法用一个命令更新所有这些版本号?

如果解决方案可以更新,不仅是 Angular,还有 jQuery 和其他 CDN 组件,那将是惊人的

我在我的项目中采用BowerGrunt;如果这些工具可以提供帮助,我非常想知道。

【问题讨论】:

    标签: javascript html cdn


    【解决方案1】:

    如果您将与可以使用的项目的最新版本同步:

    jQuery 最新: http://code.jquery.com/jquery-latest.min.js

    角度: http://code.angularjs.org/snapshot/angular.min.js

    ...

    Google CDN 未实现此最新功能。

    如果您想自己更新版本,您可以在 grunt 构建过程中使用模板渲染。 https://www.npmjs.org/package/grunt-mustache-render 例如。保留一个包含每个库版本的配置文件和一个包含您的文件的模板以及要在 html 文件中呈现的 间隙

    【讨论】:

    • 全面的答案。我喜欢小胡子的推荐。由于 AngularJS 发生重大变化的频率,我不想在生产中使用“最新”功能,但了解开发对开发很有好处。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-09
    • 1970-01-01
    • 2014-11-02
    • 2016-11-12
    • 2019-08-07
    相关资源
    最近更新 更多