grunt bower-install 一个 shimmed bower 依赖项

grunt bower-install of a shimmed bower dependency

我已经为我的应用程序安装了一些 Git 存储库,我通过执行以下操作完成了它:

bower install git://github.com/user/cooltool.git --save
grunt bower-install

然后出现以下错误:

cooltool was not injected in your file.
Please go take a look in "app/bower_components/cooltool" for the file you need, then manually include it in your file.

直接从 GitHub 存储库安装的 Bower 组件是否总是需要手动添加到我的 index.html 文件中?如果没有,如何让它正确包含脚本?

Grunt 任务都是 yo angular-fullstack 脚手架工具的一部分。

gruntfile 的 bower-install 任务如下:

// Automatically inject Bower components into the app
'bower-install': {
  app: {
    html: '<%= yeoman.app %>/views/index.html',
    ignorePath: '<%= yeoman.app %>/',
    exclude: ['bootstrap-sass']
  }
},

最终,我希望将该 cooltool Bower 组件的脚本标记注入我的 index.html Bower build:js 部分:

<!-- build:js(app) scripts/vendor.js -->
<!-- bower:js -->

    <script ...>

<!-- endbower -->
<!-- endbuild -->

执行 运行 bower install git://github.com/user/cooltool.git --save 后,为它创建了一个 Bower 目录,该目录中有一个(隐藏的).bower.json 文件,但不是主文件 bower.json 文件:

.bower.json:

{
  "name": "d3-cloud",
  "homepage": "https://github.com/jasondavies/d3-cloud",
  "version": "1.0.5",
  "_release": "1.0.5",
  "_resolution": {
    "type": "version",
    "tag": "v1.0.5",
    "commit": "83eb4128335eacdc0736ab7a6cafbdc2b124f484"
  },
  "_source": "https://github.com/jasondavies/d3-cloud.git",
  "_target": "~1.0.5",
  "_originalSource": "https://github.com/jasondavies/d3-cloud.git"
}

通常,您将以这种方式安装一些东西:

bower cache clean
bower install component --save

但是,如果添加的存储库本身没有建立 bower.json main 和 ignore 规则,您需要自己添加并检查。

您可以按以下方式进行操作:

1.- Fork the original repository for the component
2.- Add a bower.json file.
3.- Include in this file a 
    "main": ['path/to/file'], 
    "ignore":['array','of','things','to','ignore']
3.-bower install your forked git repo, and it will work