简体   繁体   English

如何在Rails应用程序中使用Bower包含修改过的javascript库?

[英]How to include modified javascript library using Bower in a Rails app?

So I'm using angular in a rails app and using bower to manage my javascript libraries. 所以我在rails应用程序中使用angular并使用bower来管理我的javascript库。 There have been a few times that have come up where I've had to modify the functionality of certain bower packages. 已经有几次出现在我必须修改某些凉亭包的功能的地方。 What I've done previously is just copy the source file pulled in by bower, make the changes, then save that in my assets directory and pull that file in directly in my application.js manifest. 我之前做的只是复制bower引入的源文件,进行更改,然后将其保存在我的assets目录中,并直接在我的application.js清单中提取该文件。

Is there a better/cleaner way to do this so that all my javascripts are still pulled in via bower? 是否有更好/更清洁的方法来做到这一点,以便所有的javascripts仍然通过凉亭拉入? I know that for gemfiles, I can fork a repo and reference that version in my gemfile, is there something similar for bower? 我知道对于gemfiles,我可以在我的gemfile中分叉一个repo并引用该版本,对于bower有类似的东西吗?

Are there any best practices here? 这里有最好的做法吗? Thanks a bunch. 谢谢一堆。

EDIT: Also I'm using a bower.json file, something like this: 编辑:我也在使用bower.json文件,如下所示:

{
  "lib": {
    "name": "bower-rails generated lib assets",
    "dependencies": {
      "angular": "latest",
        "angular-ui-router": "latest",
        "angular-animate": "latest",
        "bootstrap-sass-official": "latest",
        "angular-deckgrid":"latest",
        ...
    }
  },
  "vendor": {
    "name": "bower-rails generated vendor assets",
    "dependencies": {
      // "three.js"    : "https://raw.github.com/mrdoob/three.js/master/build/three.js"
    }
  }
}

You can do the same for bower packages. 您可以为凉亭套餐做同样的事情。 Fork the repo, make your changes, and then create your own Bower package following this . 叉回购,进行更改,然后创建自己的鲍尔包下这个 Once it has been registered, you can just bower install <your-package> directly every time :) 一旦注册,你可以直接每次直接bower install <your-package> :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM