2017-08-29 29 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

相關問題