Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

bower

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.

like image 221
raulricardo21 Avatar asked Dec 05 '13 04:12

raulricardo21


2 Answers

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.

like image 93
Kelly J Andrews Avatar answered Nov 10 '22 00:11

Kelly J Andrews


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: 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 and bower 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).
like image 9
Vivian Spencer Avatar answered Nov 10 '22 02:11

Vivian Spencer