简体   繁体   中英

Ember-simple-auth how to depend on it in an addon?

I am developing several webapps, and so, I decided to create an addon with all the ccs and bootstrap, moment and other addons to be reused. One addon I want to use in my foundation addon is ember-simple-auth. I declared it in as dependency, but is not included in the project when I run. And so, in the browser I get an error of missing files.

According to @marcoow where , this sould be enough.

Application package.json :

"devDependencies": {
  "broccoli-asset-rev": "^2.6.0",
  "ember-ajax": "^3.0.0",
  "ember-cli": "~2.14.2",
  "ember-cli-app-version": "^3.0.0",
  "ember-cli-babel": "^6.3.0",
  "ember-cli-dependency-checker": "^2.0.1",
  "ember-cli-eslint": "^4.2.0",
  "ember-cli-htmlbars": "^2.0.3",
  "ember-cli-htmlbars-inline-precompile": "^1.0.2",
  "ember-cli-inject-live-reload": "^1.7.0",
  "ember-cli-moment-shim": "^3.4.0",
  "ember-cli-qunit": "^4.0.0",
  "ember-cli-sass": "^7.0.0",
  "ember-cli-shims": "^1.2.0-beta.2",
  "ember-cli-sri": "^2.1.0",
  "ember-cli-uglify": "^2.0.0-beta.1",
  "ember-data": "^2.14.3",
  "ember-export-application-global": "^2.0.0",
  "ember-load-initializers": "^1.0.0",
  "ember-resolver": "^4.4.0",
  "ember-models-table": "^1.13.0",
  "ember-simple-auth": "^1.4.0",
  "ember-source": "^2.14.1",
  "loader.js": "^4.6.0",
  "universe-gui": "0.2.0"
},

Addon package.json :

"dependencies": {
  "ember-cli-babel": "^6.8.1",
  "ember-cli-flash": "^1.4.3",
  "ember-cli-htmlbars": "^2.0.3",
  "ember-cli-sass": "^7.0.0",
  "ember-crumbly": "1.0.7",
  "ember-i18n": "5.0.2",
  "ember-moment": "7.3.0",
  "ember-simple-auth": "^1.4.0",
  "ember-truth-helpers": "1.3.0"
}

You can use the afterInstall hook in the default blueprint:

ember g blueprint name-of-your-addon

module.exports = {
  normalizeEntityName: function() {},

  afterInstall: function(options) {
    return RSVP.all([
      this.addPackageToProject('npm-package'),
      this.addAddonToProject('ember-addon')
    ]);
  }
};

I also struggled with this when developing an addon.
This article helped a lot (even though its somewhat outdated now), along with the official documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM