Search code examples
ember.jsember-cli-addonsember-addon

ember.js addon: how to manipulate files?


We have 5+ ember.js projects. I've extracted all common features as an addon. Other projects depend my addon with package.json (as npm module).

I want to do some post-processing after my addon upgraded on any project (via npm install). I need to do such processing:

  • Override /app/styles.css file.
  • Override router.js
  • Put some files on /translations directory.

Is there any hook to do these? Is there any documentation for hooks?


Solution

  • What we did:

    • Override /app/styles.css file: We are not using app/styles files. We created a bower addon to keep our styles. In our ember addon's index.js file, there is a hook called included(app). We use app.import calls to place our styles to the apps.
    • Override router.js: We are not overriding router.js. Modification needs occur very rarely. So we announce it on our releases if any modification is needed.
    • Put some files on /translations directory: After upgrading ember-intl#2.8. We will not need to modify /translations directory.