What is the "main file" property when doing bower init?

raulricardo21 picture raulricardo21 · Dec 5, 2013 · Viewed 37.3k times · Source

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.

Answer

Kelly J Andrews picture Kelly J Andrews · Jan 21, 2014

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.