如何使用Webpack为Aurelia供应商文件和Aurelia应用程序文件分别获取捆绑包?

时间:2016-09-19 04:19:55

标签: webpack aurelia aurelia-framework

我有这个webpack的基本设置:

{
    context: rootDir,
    entry: {
        main: scriptsPath + "Main.ts",
        app: [/* this is filled by the aurelia-webpack-plugin */]
    },
    output: {
        path: destDir,
        library: "[name]",
        filename: "[name]-bundle.js"
    },
    module: {...loaders},
    resolve: {...},
    plugins: [
        new webpack.optimize.CommonsChunkPlugin({
            name: "main",
            minChunks: Infinity
        }),            
        new AureliaWebpackPlugin({
            src: appPath,
            root: rootDir
        }),
    ]
};

我的Main.ts仅导入骨架应用程序附带的所有aurelia-*包,以及Jquery和Bootstrap。正如预期的那样,我得到了两个名为main-bundle.jsapp-bundle.js的独立包。但是在运行时,浏览器会抛出以下错误:

Error: Cannot find module './aurelia-templating-resources/compose'.

我已将其追溯到aurelia webpack插件,但未生成webpackContextResolve函数使用的正确上下文映射。我对如何解决这个问题感到茫然。任何帮助表示赞赏。

环境详情:

  • Windows 7 x64
  • Node v6.0.0
  • NPM v3.10.7
  • Webpack v1.13.2
  • Aurelia v1.1.0

更新

我按照this issue上的说明更新了 Webpack到2.1.0-beta.24 ,但仍然遇到此错误以及许多其他类似错误:

Error: Cannot find module './aurelia-templating-resources/binding-mode-behaviors'. app-bundle.js:42:9
Error: Cannot find module './aurelia-templating-resources/repeat'. app-bundle.js:42:9
Error: Cannot find module './aurelia-templating-resources/with'. app-bundle.js:42:9
Error: Cannot find module './aurelia-templating-resources/if'. app-bundle.js:42:9
Error: Cannot find module './aurelia-templating-resources/compose'. app-bundle.js:42:9
Error: Cannot find module './aurelia-templating-router/route-href'. app-bundle.js:42:9
Error: Cannot find module './aurelia-templating-resources/update-trigger-binding-behavior'. app-bundle.js:42:9
Error: Cannot find module './aurelia-templating-router/router-view'. app-bundle.js:42:9
Error: Cannot find module './aurelia-templating-resources/signal-binding-behavior'. app-bundle.js:42:9
Error: Cannot find module './aurelia-templating-resources/debounce-binding-behavior'. app-bundle.js:42:9
Error: Cannot find module './aurelia-templating-resources/sanitize-html'. app-bundle.js:42:9
Error: Cannot find module './aurelia-templating-resources/replaceable'. app-bundle.js:42:9
Error: Cannot find module './aurelia-templating-resources/hide'. app-bundle.js:42:9
Error: Cannot find module './aurelia-templating-resources/show'. app-bundle.js:42:9
Error: Cannot find module './aurelia-templating-resources/throttle-binding-behavior'. app-bundle.js:42:9
Error: Cannot find module './aurelia-templating-resources/focus'.

0 个答案:

没有答案