Bower Powerful management Web package management Tools _ Other integrated

Source: Internet
Author: User
Tags jquery library

Bower Introduction

Bower Official Address: http://bower.io/

Bower is another Open-source project for Twitter, using Nodejs development for Web package management. If more and more open source projects are hosted on GitHub, Bower only need to add a configuration file to the GitHub project to use the installation package Bower way. As package management, Bower can provide new Web packages, update Web packages, delete Web packages, publish Web package features, and manage package dependencies. Web packages are generally considered composed of html+css+javascript.

Quick Start: Solving practical problems

Imagine that we started a new webapp, need to use the jquery library, the previous practice is to go to the official web down the latest Jquery.js files under the project directory. If there is a bower, the job is simple.

Install Bower First (make sure you have a node environment first)

Copy Code code as follows:

NPM Install Bower-g


Running in the project directory

Bower Install jquery
After running successfully, the Components folder will be included in the project, the jquery folder in the folder, the jquery folder will have the latest jquery file.

This does not explain his NB place, imagine the following scene, jquery upgrade, is not down once jquery? Bower can do this:

Bower Update jquery
You can automatically upgrade to the latest version of jquery.

Then suppose we need to use Bootstrap,bootstrap is not a file, there are css,js and pictures. JS also relies on jquery, if you use bower:

Bower Install Bootstrap
Bower will automatically down the latest code from the GitHub, and will automatically take the dependency packet jquery down once.

More Features

The students who are familiar with NPM must be familiar with the bower and have many similar ideas, such as

View the dependency package structure

Bower List
├─┬bootstrap#2.2.2
│└──jquery#1.8.3
├──jquery#1.8.3
├──requirejs#2.1.2
└──rgraph2#d8f957ae056a79344807c9cb25fbfe3f4b855aa2
AD:RGRAPH2 is a recently researched open source project that has been published to Bower. But there's a problem with the version.

Bower LS in the same way, Bower also provides a more considerate dependency package view view

Bower LS--paths
{
"Bootstrap": [
"Components/bootstrap/docs/assets/js/bootstrap.js",
"Components/bootstrap/docs/assets/css/bootstrap.css"
],
"jquery": "Components/jquery/jquery.js",
"Requirejs": "Components/requirejs",
"Rgraph2": [
"Components/rgraph2/lib/raphael-min.js",
"Components/rgraph2/lib/rgraph2.js"
]
}
You can generate the file directly, and it can be used for the REQUIREJS,SEAJS module configuration file.

Install the specified version of the library

Bower Install jquery#1.7.2
Direct Search Package

#搜索jquery库以及插件
Bower Search jquery
Delete Package

Bower Uninstall jquery
If the package is dependent, it cannot be deleted

Update package to latest version

Bower Update jquery
Find packages within a project

Bower Lookup jquery
View package Information

Bower Info jquery
Publish your own Web package

If you use GitHub managed code, add Component.json as a configuration file in the root directory of the warehouse (similar to Package.json in Nodejs). Still taking RGRAPH2 as an example
Copy Code code as follows:

{
"Name": "Rgraph2",
"Version": "1.0.0",
"Main": [
"./lib/raphael-min.js",
"./lib/rgraph2.js"
],
"Dependencies": {},
"Readmefilename": "Readme.md",
"_id": "rgraph2@1.0.0",
"description": "Web Graph implementation by Raphaeljs",
"Repository": {
' type ': ' Git ', www.jb51.net
"url": "Git://github.com/hafeyang/rgraph2.git"
}
}

Specifies the package name and version versions, and the file list main, which relies on dependencies,git information repository. The dependent declaration format is:

Copy Code code as follows:

"Devdependencies": {
"Uglify-js": "1.2.6"
, "Jshint": "0.6.1"
, "Recess": "1.0.3"
, "Connect": "2.1.3"
, "Hogan.js": "2.0.0"
}

The

is comoponent.jsonpush into the warehouse. Then register

 bower Register RGRAPH2 git://github.com/hafeyang/rgraph2.git
so that you can use the install command to manage the RGRAPH2 package. The

Summary

Bower provides an ideal way to manage Web packages. With many of NPM's ideas, it should be said that NPM is a very ideal package management tool, Nodejs in the early time to put forward the package management tools, the development of NODEJS Package specification, for the entire ecological circle construction is very meaningful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.