简体   繁体   English

Bower.json 只安装单个文件

[英]Bower.json install only single file

I am a bower newbie.我是一个凉亭新手。 How can I download only a single file from GitHub instead of the entire set of files?如何仅从 GitHub 下载单个文件而不是整个文件集? I just want the latest fuelux.min.js file from this link and I want to put it in my plugins directory.我只想要这个链接中最新的fuelux.min.js文件,我想把它放在我的插件目录中。

{
  "name": "my app",
  "version": "1.0",
  "dependencies": {
    "angular-local-storage": "latest",
    "fuelux":"latest"
    },
  "install" : {
    "path" : {
      "js": "plugins"
      }
  }
}

The idea of bower is that you include the entire published contents of the repository/package which is then installed by a developer through bower. bower 的想法是您包含存储库/包的全部已发布内容,然后由开发人员通过 bower 安装。 You use your build system (grunt, broccoli, etc) to pick any files from that which need to be included in your own distribution.您可以使用构建系统(grunt、broccoli 等)从需要包含在您自己的发行版中的文件中挑选任何文件。

If for some reason you really only want that single file you'll just have to include it in your application manually.如果由于某种原因您真的只想要该单个文件,您只需手动将其包含在您的应用程序中。

I agree with the answer provided by @Leeft.我同意@Leeft 提供的答案。 Should the circumstance arise when you do only need one file you can reference the Raw file listed on github in your install.如果情节出现时,只需要一个文件,你可以参考你安装在GitHub上列出的RAW文件。

bower install https://raw.githubusercontent.com/chrishunt/retinajs/master/src/retina.js --save

This will include the dependency in your bower.json file这将在您的bower.json文件中包含依赖bower.json

"dependencies": {
    "retina": "https://raw.githubusercontent.com/chrishunt/retinajs/master/src/retina.js"
}

If you use wiredep with bower, you can add an overrides section to your package's bower.json, like:如果您将wiredep与bower一起使用,您可以在包的bower.json 中添加一个覆盖部分,例如:

"overrides": {
  "fuelux": {
    "main": [
      "dist/js/fuelux.min.js"
    ]
  }
}

I agree with simple the one thing I don't enjoy about NPM and Bower is that they bloat the file-size on every project, sometimes when there's no need to.我同意简单的一点,我不喜欢 NPM 和 Bower 的一件事是它们使每个项目的文件大小膨胀,有时是在没有必要的情况下。

Take a look at this NPM package that allows to install specific files and not the entire repo:看看这个允许安装特定文件而不是整个 repo 的 NPM 包:

https://github.com/blittle/bower-installer https://github.com/blittle/bower-installer

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

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