问题
I'm creating a javascript library that I want make available through Bower to my internal company. I'm using Grunt to build my library.
My issue is that grunt's convention is to use package.json
to define dependencies, library versions, dependencies, etc.
Bower, on the other hand, assumes that that same information is found in a component.json
file.
What's the intended use of these two? They seem to serve essentially the same purpose. Do I need to create both and cut and paste the shared information?
回答1:
We've gotten a lot of these kinds of question and everyone assumes we could share a lot metadata between these formats, but the reality is that only the name
and version
fields are sharable and only the version
field changes regularly. If you find it cumbersome having to update two fields when you release something, there are tools out there that can automate this, eg. grunt-bumpx.
回答2:
package.json
is intended for back-end purposes, in this case specify grunt tasks, node dependencies, etc. In the other side, bower.json
is intended for front-end purposes.
来源:https://stackoverflow.com/questions/16488329/defining-package-information-in-component-json-and-package-json