Bower.json install only single file

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 11:38:16

问题


I am a bower newbie. How can I download only a single file from GitHub instead of the entire set of files? I just want the latest fuelux.min.js file from here (https://raw.githubusercontent.com/ExactTarget/fuelux/master/dist/js/fuelux.min.js) and I want to put it in my plugins directory.

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

回答1:


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. You use your build system (grunt, broccoli, etc) to pick any files from that which need to be included in your own distribution.

If for some reason you really only want that single file you'll just have to include it in your application manually.




回答2:


I agree with the answer provided by @Leeft. Should the circumstance arise when you do only need one file you can reference the Raw file listed on github in your install.

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

This will include the dependency in your bower.json file

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



回答3:


If you use wiredep with bower, you can add an overrides section to your package's bower.json, like:

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



回答4:


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.

Take a look at this NPM package that allows to install specific files and not the entire repo:

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



来源:https://stackoverflow.com/questions/25557669/bower-json-install-only-single-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!