简体   繁体   English

Ember-simple-auth如何在插件中依赖它?

[英]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. 我正在开发多个Web应用程序,因此,我决定创建一个包含所有cc和bootstrap,moment和其他插件的插件。 One addon I want to use in my foundation addon is ember-simple-auth. 我想在基础插件中使用的一个插件是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. 根据@marcoow where ,这足够了。

Application package.json : 应用程序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 : 插件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: 您可以在默认蓝图中使用afterInstall挂钩:

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 . 这篇文章以及官方文档对我们很有帮助(即使现在有些过时了)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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