As Ember developer for a while, I always wonder to know how to create an Ember Addon? At this time, I was given such opportunity, and I want to share how I created Ember Addon.
create an addon folder by running ember addon <NAME>
, in my case, the name is stupid-switch
. ember addon stupid-swtich
Go to package.json
to remove ember-welcome-pag from devDependencies
and add "ember-cli-htmlbars": "^1.1.1"
(your version may vary) to dependencies
. You may need to run rm node_modules/ember-welcome-page
if installed perviously.
Now, run ember s
Next step is to actually create addons, after run ember g component stupid-switch
as usual, you will notice the files structure will be in the addon
director instead of app
directory.
Do your thing to customize this component.
You may wondering why my component is not showing up. You need to run ember generate template application
to create a gloal applicaiton template and put your component
(s) inside.
Go to /tests/dummy/app/templates/application.hbs and put your component
(s) inside.
Write test coverage perferably 100%, otherwise you are doomed to be the only developers who is not afraid of using crappy addons.
My stupid-switch: http://github.com/ldong/stupid-switch