What is the use of property main file when you run bower init? I have been looking and many people says that it currently has no purpose.
Is that true? Bower's documentation doesn't explain it either.
According to the Bower.io documentation
main
Recommended Type: String or Array of String
The primary acting files necessary to use your package. While Bower does not directly use these files, they are listed with the commands bower list --json andbower list --paths, so they can be used by build tools.
Preprocessor files like CoffeeScript should be compiled.Do not include minified files.Filenames should not be versioned (Bad: package.1.1.0.js; Good: package.js).
I think it's more for the package management, and build tools like Grunt and Brunch. For example, Bootstrap's bower.json looks like :
{
"name": "bootstrap",
"version": "3.0.3",
"main": [
"./dist/css/bootstrap.css",
"./dist/js/bootstrap.js",
"./dist/fonts/glyphicons-halflings-regular.eot",
"./dist/fonts/glyphicons-halflings-regular.svg",
"./dist/fonts/glyphicons-halflings-regular.ttf",
"./dist/fonts/glyphicons-halflings-regular.woff"
],
"ignore": [
"**/.*",
"_config.yml",
"CNAME",
"composer.json",
"CONTRIBUTING.md",
"docs",
"js/tests"
],
"dependencies": {
"jquery": ">= 1.9.0"
}
}
When I build in Brunch, it pulls these files from my bower_components folder in my public folder.
According to Bower's JSON Specification (https://github.com/bower/spec/blob/master/json.md#main), the "main" property is used to list the files primarily used in the project. The files listed are not actually used by Bower in any way, they are apparently there for the purpose of being used by other build tools.
Here is the official specification:
main
Recommended
Type:StringorArrayofStringThe primary acting files necessary to use your package. While Bower does not directly use these files, they are listed with the commands
bower list --jsonandbower list --paths, so they can be used by build tools.
- Preprocessor files like CoffeeScript should be compiled.
- Do not include minified files.
- Filenames should not be versioned (Bad: package.1.1.0.js; Good: package.js).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With