【问题标题】:Bower and dependency developmentBower 和依赖项开发
【发布时间】:2014-10-26 18:16:34
【问题描述】:

我正在使用带有 Yeoman 生成器的 angularJS 开发应用程序 myapp。这包括管理依赖项的 Bower,以及将这些依赖项连接到 index.html 的 Grunt(=它生成 index.html 文件,其中包含基于 Bower 配置和依赖项的所有脚本和链接)。

我有 angular-gantt 作为依赖项,它通过 Bower 作为单个 .js 文件分发。

因为我想为angular-gantt 做出贡献,所以我使用bower link 从本地克隆的 git 存储库中读取源代码。

但我仍然需要从 myapp 覆盖 bower main 属性以使用 javascript source files from this folder,而不是 single distributed one

有没有一种自动化的方法来解决这个问题,而不是一一列出每个源文件?是否有一些生成器可以从源代码构建此列表?

myapp/bower.json

{
  "name": "myapp",
  "version": "0.0.0",
  "dependencies": {
    ...
    "angular-gantt": "~0.6.1",
    ...
  },
  "devDependencies": {
    ...
  },
  "overrides": {
    ...
    "angular-gantt": {
      "main": [ // <= How to avoid listing those files manually ?
        "file1.js",
        "file2.js",
        "file3.js",
        "file4.js",
        ....
      ]
    },
    ...
  }
}

angular-gantt/bower.json

{
  "name": "angular-gantt",
  "version": "0.6.1",
  "homepage": "https://github.com/Schweigi/angular-gantt",
  "authors": [
    "Schweigi"
  ],
  "description": "A Gantt chart directive for Angular.js without any other dependencies.",
  "main": [
    "./assets/angular-gantt.js",
    "./assets/gantt.css"
  ],
  .......
}

【问题讨论】:

  • 这是一个有趣的问题。我知道 Visual Studio 允许您将 JavaScript cmets 放入文件中声明它所依赖的内容,但我不确定是否有非 Visual Studio 解决方案。
  • 为什么要覆盖 bower main 属性而不使用单个分布式?
  • 如果我进行更改,我不希望它们位于正确的源文件中。我不想花时间将更改从分布式文件复制/粘贴到源文件。

标签: javascript angularjs yeoman bower


【解决方案1】:

如果其他人有这个问题,这是我终于找到的解决方案。

angular-gantt 正在使用 grunt concatuglify 两者都支持 sourceMap 选项。启用后,将生成 sourceMap 以及分发 .js 文件。

Intellij IDEA can read this sourcemap 从真实源代码进行调试,同时将分布式文件保存在运行时环境中。这不需要配置,因为 sourceMap 文件名作为注释添加到分发 .js 文件的末尾。

使用 grunt 文件watch,可以在更改源时自动生成缩小文件。

因此,通过使用支持 sourceMap 的 IDE,并使用 grunt watch 检查更改并根据源更改构建分布式 .js 文件,问题就解决了。

【讨论】:

    猜你喜欢
    • 2013-08-18
    • 2013-10-20
    • 1970-01-01
    • 2014-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多