Creating your own bower component
This post will explain, how to create our own bower component, from scratch.
node, npm and git
- Install Bower by using npm with the command npm install -g bower
- Once Bower is successfully installed, Create a bower.json file for your package with bower init.
- Now it will prompt you to answer a few questions. Please answer them. You can find more information about the questions here
- name property is a mandatory property while creating a bower.jsonfile. description, main, moduleType, license, ignore, keywords are recommended properties while creating a bower.json file
Once you are successfully answered the questions, you should see something like below screen
This will create a file with the name bower.json in the same directory. You can open the file and cross check whether the file is created as per the values you have given while creating it.
With this, creation of bower.json file is finished successfully. Now it’s time to
register this package.
- There should be a valid bower.json in the project’s root directory.
- The package should use Semantic Versioning
- And your package must be publically available at a Git endpoint.
- And then you need to run bower register my-package-name < git-endpoint >
Example : bower register ionic-datepicker email@example.com:rajeshwarpatlolla/ionic-datepicker.git
Once you register the package successfully, then anyone can install the component from the command line like bower install my-package-name
Before you try to unregister your package you need to login to bower first. Please follow the below steps to unregister the package.
- Run the command bower login
- Then enter the login details to login.
- Then enter bower unregister package to unregister the registered package.
Now i am going to give an example of a bower component which i created myself. With this section you should
get a good idea on how to create a bower component. Please check the below link to see how the bower.json is created.
Please check the following things in the above repository
- It should be a public repository
- It should have a valid bower.json file