bower.json
is used for configuring packages that can be used as a dependency of another package. This is similar to Node’s package.json
or Ruby’s Gemfile
.
You can interactively create a bower.json with bower init
.
{
"name": "blue-leaf",
"description": "Physics-like animations for pretty particles",
"main": [
"js/motion.js",
"sass/motion.scss"
],
"dependencies": {
"get-size": "~1.2.2",
"eventEmitter": "~4.2.11"
},
"devDependencies": {
"qunit": "~1.16.0"
},
"moduleType": [
"amd",
"globals",
"node"
],
"keywords": [
"motion",
"physics",
"particles"
],
"authors": [
"Betty Beta <[email protected]>"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"private": true
}
Required
Type: String
The name of the package as stored in the registry.
- Must be unique.
- Should be slug style for simplicity, consistency and compatibility. Example:
unicorn-cake
- Lowercase, a-z, can contain digits, 0-9, can contain dash or dot but not start/end with them.
- Consecutive dashes or dots not allowed.
- 50 characters or less.
Recommended
Type: String
Any character. Max 140.
Help users identify and search for your package with a brief description. Describe what your package does, rather than what it's made of. Will be displayed in search/lookup results on the CLI and the website that can be used to search for packages.
Deprecated
Use git or svn tags instead. This field is ignored by Bower.
Recommended
Type: String
or Array
of String
The entry-point files necessary to use your package. Only one file per filetype.
Entry-point files have module exports and may use module imports. While Bower does not directly use main
files, they are listed with the commands bower list --json
and bower list --paths
, so they can be used by build tools.
Let's say your package looks like this:
package
js/
motion.js
run.js
walk.js
sass/
motion.scss
run.scss
walk.scss
img/
motion.png
walk.png
run.png
fonts/
icons.woff2
icons.woff
dist/
movement.js
movement.min.js
movement.css
movement.min.css
motion.js
has module imports for run.js
and walk.js
. motion.scss
has module imports for run.scss
and walk.scss
. main
would be
"main": [
"js/motion.js",
"sass/motion.scss",
]
Image and font files may be used or referenced within the JS or Sass files, but are not main
files as they are not entry-points.
- Use source files with module exports and imports over pre-built distribution files.
- Do not include minified files.
- Do not include assets files like images, fonts, audio, or video
- Filenames should not be versioned (Bad:
package.1.1.0.js
; Good:package.js
). - Globs like
js/*.js
are not allowed.
Recommended
Type: String
or Array
of String
The type of module defined in the main
JavaScript file. Can be one or an array of the following strings:
globals
: JavaScript module that adds to global namespace, usingwindow.namespace
orthis.namespace
syntaxamd
: JavaScript module compatible with AMD, like RequireJS, usingdefine()
syntaxnode
: JavaScript module compatible with node and CommonJS usingmodule.exports
syntaxes6
: JavaScript module compatible with ECMAScript 6 modules, usingexport
andimport
syntaxyui
: JavaScript module compatible with YUI Modules, usingYUI.add()
syntax
Recommended
Type: String
or Array
of String
SPDX license identifier or path/url to a license.
Recommended
Type: Array
of String
A list of files for Bower to ignore when installing your package.
Note: symbolic links will always be ignored. However bower.json
will never be ignored.
The ignore rules follow the same rules specified in the gitignore pattern spec.
Default ignores are as follows:
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
Recommended
Type: Array
of String
Same format requirements as name.
Used for search by keyword. Helps make your package easier to discover without people needing to know its name.
Type: Array
of (String
or Object
)
A list of people that authored the contents of the package.
Either:
"authors": [
"John Doe",
"John Doe <[email protected]>",
"John Doe <[email protected]> (http://johndoe.com)"
]
or:
"authors": [
{ "name": "John Doe" },
{ "name": "John Doe", "email": "[email protected]" },
{ "name": "John Doe", "email": "[email protected]", "homepage": "http://johndoe.com" }
]
Type: String
URL to learn more about the package. Falls back to GitHub project if not specified and it’s a GitHub endpoint.
Type: Object
The repository in which the source code can be found.
"repository": {
"type": "git",
"url": "git://github.com/foo/bar.git"
}
Type: Object
Dependencies are specified with a simple hash of package name to a semver compatible identifier or URL.
- Key must be a valid name.
- Value must be a valid semver range, a Git URL, or a URL (inc. tarball and zipball).
- Git URLs can be restricted to a reference (revision SHA, branch, or tag) by appending it after a hash, e.g.
https://github.com/owner/package.git#branch
. - Value can be an owner/package shorthand, i.e. owner/package. By default, the shorthand resolves to GitHub -> git://github.com/{{owner}}/{{package}}.git. This may be changed in
.bowerrc
shorthand_resolver. - Local paths may be used as values for local development, but they will be disallowed when registering.
Type: Object
Same rules as dependencies
.
Dependencies that are only needed for development of the package, e.g., test framework or building documentation.
Type: Object
Dependency versions to automatically resolve with if conflicts occur between packages.
Example:
"resolutions": {
"angular": "1.3.0-beta.16"
}
Type: Boolean
If set to true
, Bower will refuse to publish it. This is a way to prevent accidental publication of private repositories.