bower install take repo, not specific files in main

試著忘記壹切 提交于 2019-12-22 08:24:34

问题


I am trying to install some js files via bower. My repo has a bower.json with a main property, however the whole repo gets installed to components/, not just the files in the dist/custom/ dir.

Here is what my bower.rc looks like

    {
        "name": "jquery-m",
        "version": "2.0.2mup",
        "description": "Meetup custom build of jQuery 2.0, used on mobile",
        "main": [ "./dist/custom/" ],
        "license": "MIT"
    }

Is this the way bower is supposed to work? I thought it was possible just to specify certain files with your main property.


回答1:


Yes, this is how Bower is meant to work. Bower-installer looks like a more lightweight solution than Grunt to solve the exact requirement you're describing and get just the files you need to be deployed to production.




回答2:


Yes, that's how Bower works.

It always look for the matching tag on the repo; if cannot find one, it goes with the default branch, and download it.

The unique usage I've seen so far for the main property of a bower.json file is for integration, for example with build tools, like Grunt (there are lots of other bower related tasks, just Google around) and others.




回答3:


This is a common misconception.

As stated in Bower documentation, the main property is a string/array listing the primary endpoints of your package.

Bower package maintainers (and maybe users, using the overrides property) can use the ignore property, which is an array of paths not needed in production that you want Bower to ignore when installing your package.

Example:

{
  "name": "stackoverflow",
  "version": "1.0.0",
  "ignore": [
    "test/**",
    ".jshintrc"
  ],
  "dependencies": {
    "foo": "~1.1"
  }
}


来源:https://stackoverflow.com/questions/17057038/bower-install-take-repo-not-specific-files-in-main

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