0

我将 systemjs-builder 与 angular2 一起使用。
我想要每个模块文件的构建器捆绑文件。
例如:我的结构如下

Main.ts

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule }              from './AppModule';

AppModule.ts

import {NgModule, CUSTOM_ELEMENTS_SCHEMA, ErrorHandler} from "@angular/core";
import {CommonModule, LocationStrategy, HashLocationStrategy} from "@angular/common";
import {appRoutingProviders, routing} from "./Routes";
import {LoginComponent} from "./components/user/LoginComponent";
import {ErrorComponent} from "./components/common/errorPage/ErrorComponent";

Routes.ts 

{path: "accounts",loadChildren: 'app/components/account/AccountModule#AccountModule'},
{path: "contacts",loadChildren: 'app/components/contact/ContactModule#ContactModule'}

现在我曾经 builder.bundle('[app/**/*]',bundle.js)将所有组件构建到一个文件中,所以大小非常大。
我想将Main.ts(AppModule.ts,AppModule 中的所有组件......)额外库(angular2/core......)中的所有依赖项构建到“bundle.js”。
以及to 的所有依赖项, AccountModuletoAccountModule.js的所有依赖ContactModuleContactModule.js
在生产中使用延迟加载。
这个问题的任何解决方案,谢谢

4

1 回答 1

0

如果您生成单个捆绑包...只能加载它。您必须创建不同的捆绑包。

例如,一个用于 Angular 和 rxjs 的包,另一个用于主 ng-module,另一个用于每个惰性 ng-module。

我最近几天一直在测试它,看看这个分支:

https://github.com/tolemac/systemjs-test/tree/bundle-format-system?files=1

这是一个小角度应用程序的示例,使用了供应商、应用程序和惰性模块的捆绑包。

克隆 repo,签出“bundle-format-system”分支,“npm install”和“gulp bundle”

于 2017-03-19T20:02:46.523 回答