Bower.json install only single file

2019-08-03 17:13发布

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"
      }
  }
}

4条回答
Fickle 薄情
2楼-- · 2019-08-03 17:35

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"
    ]
  }
}
查看更多
爷的心禁止访问
3楼-- · 2019-08-03 17:37

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.

查看更多
相关推荐>>
4楼-- · 2019-08-03 17:39

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

查看更多
你好瞎i
5楼-- · 2019-08-03 17:43

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"
}
查看更多
登录 后发表回答