2017-08-29 30 views
1

我使用最新的aurelia-cli设置了新的Aurelia项目。我选择使用webpack和TypeScript。看起来,在使用webpack时将插件添加到项目中的文档方式并不多。我想补充奥里利亚-auth的在我试图将它添加到奥里利亚节在我的package.json:在新的webpack选项中使用Aurelia CLI,我将如何添加对aurelia-auth的引用

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

然后使用它:

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

但它不会出现一切都使它在:

Unhandled rejection Error: Unable to find module with ID: aurelia-auth/auth-filter

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

回答

4

为的WebPack:

webpack.config.js,有plugins物业内的ModulesDependenciesPlugin项。添加奥里利亚-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" 
     } 
    ] 
+0

,对于默认RequireJS配置工作,但是当我模块加载设置的WebPack存在aurelia.json没有相关部分。我添加了它,看它是否会起作用,但没有骰子。它仍然会给出同样的错误。 – Jereme

+0

对不起,我的错。我用webpack解决方案更新了我的帖子。也许这对你有帮助。 –

+0

这样做,谢谢! – Jereme

相关问题