1

我使用最新的 aurelia-cli 建立了一个新的 Aurelia 项目。我选择使用 webpack 和 TypeScript。在使用 webpack 将插件添加到项目中时,似乎没有太多的文档方式。我想添加 aurelia-auth。我尝试将它添加到我的 package.json 中的 aurelia 部分:

  "aurelia": {
    "build": {
      "resources": [
        "aurelia-auth"
      ]
    }
  }

然后使用它:

aurelia.use
  .standardConfiguration()
  .feature(PLATFORM.moduleName('resources/index'))
  .plugin(PLATFORM.moduleName('aurelia-auth'), (baseConfig)=>{
     baseConfig.configure({});
  });

但似乎并非一切都成功了:

未处理的拒绝错误:无法找到具有 ID 的模块:aurelia-auth/auth-filter

使用 Aurelia CLI 和 webpack 捆绑和运行应用程序时添加引用的正确方法是什么?

4

1 回答 1

4

对于 Webpack:

在 中,属性内webpack.config.js有一个ModulesDependenciesPlugin条目。plugins在其中添加 aurelia-auth,例如:

new ModuleDependenciesPlugin({
  'aurelia-testing': [ './compile-spy', './view-spy' ],
  'aurelia-auth': [ './auth-filter' ]
}),

对于 RequireJS: 您应该将插件添加到您aurelia.jsonbuild.bundles.dependencies属性中。

尝试以下操作:

    "dependencies": [
      ...,
      {
        "name": "aurelia-auth",
        "path": "../node_modules/aurelia-auth/dist/amd",
        "main": "aurelia-auth"
      }
    ]
于 2017-08-30T16:26:23.793 回答