【发布时间】:2017-01-21 03:38:35
【问题描述】:
我想在一个也被捆绑的 app.js 中需要来自 webpack 的两个捆绑文件。我的文件夹如下所示:
MyApp
|-app
| -app.js <-this gets bundled
|-hero
| -hero.module <- this gets also bundled
| -some other stuff that will be bundled in hero.bundle.js
|-crisis
| -crisis.module <- gets bundled
| -more stuff that gets bundled in crisis.bundle.js
-
到目前为止一切顺利。 我想在 app.js 中需要 hero.bundle.js 和 risk.bundle.js,因为我在 app.js 中使用我的组件路由器延迟加载/路由。 但是我经常收到错误,找不到模块。 要求之一的示例语法:
path: '/heroes/...',
name: 'Heroes',
loader: function () {
// lazy load Heroes
return $ocLazyLoad.load([require('./dist/heroes.bundle.js')])
.then(function () {
return 'heroes';
});
}
我做错了吗?
提前谢谢:)
【问题讨论】:
-
我实际上在 webpack.config.js 中创建了带有入口和输出的包,而不是 CommonsChunk。唯一的问题是如何将我的 bundle.js 文件包含到 javascript 文件中,而不是 html
标签: angularjs webpack bundle router