如何在Systemjs构建器任务中包含zone.js,reflect-metadata等?

时间:2016-11-10 13:10:51

标签: javascript angular systemjs systemjs-builder

我正在使用system.js和systemjs构建器创建一个dist文件夹,其中包含我的angular2应用程序的所有打包javascript文件。

它工作得非常好,除了它不包含以下文件,这些文件目前静态包含在index.html中:

  • node_modules / zone.js / DIST / zone.js
  • node_modules /反映元数据/ Reflect.js
  • node_modules / systemjs / DIST / system.src.js
  • node_modules / ESRI系统-JS / DIST / esriSystem.js

如何强制systemjs构建器包含这些依赖项?

库-bundle.js:

var SystemBuilder = require('systemjs-builder');
var builder = new SystemBuilder();
builder.loadConfig('./systemjs.config.js').then(function() {
  return builder.bundle(
    'app - [app/**/*]', // build app and remove the app code - this leaves only 3rd party dependencies
    'dist/libs-bundle.js'
  );
}).then(function() {
  console.log('library bundles built successfully!');
});

APP-bundle.js

var SystemBuilder = require('systemjs-builder');
var builder = new SystemBuilder();
builder.loadConfig('./systemjs.config.js').then(function() {
  return builder.bundle(
    'app - dist/libs-bundle.js', // build the app only, exclude everything already included in dependencies
    'dist/app-bundle.js'
  );
}).then(function() {
  console.log('Application bundles built successfully!');
});

systemjs.config.js:

/**
 * System configuration for Angular 2 samples
 * Adjust as necessary for your application needs.
 */
(function(global) {
  System.config({
    paths: {
      // paths serve as alias
      'npm:': 'node_modules/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      app: 'dist',
      // angular bundles
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
      // other libraries
      'rxjs': 'npm:rxjs',
      'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
      'ng2-slim-loading-bar': 'npm:/ng2-slim-loading-bar',
      'ng2-toasty': 'npm:/ng2-toasty',
      'primeng': 'npm:/primeng',
      '@angular2-material/core': 'npm:/@angular2-material/core',
      '@angular2-material/grid-list': 'npm:/@angular2-material/grid-list'
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        main: './main.js',
        defaultExtension: 'js'
      },
      rxjs: {
        defaultExtension: 'js'
      },
      'esri-mods': {
        defaultExtension: 'js'
      },
      'angular2-in-memory-web-api': {
        main: './index.js',
        defaultExtension: 'js'
      },
      'ng2-slim-loading-bar': {
        main: 'index.js',
        defaultExtension: 'js'
      },
      'ng2-toasty': {
        main: 'index.js',
        defaultExtension: 'js'
      },
      'primeng': {
        defaultExtension: 'js'
      },
      '@angular2-material/core': {
        main: './core.umd.js',
        defaultExtension: 'js'
      },
      '@angular2-material/grid-list': {
        main: './grid-list.umd.js',
        defaultExtension: 'js'
      }
    },
    meta: {
      'esri/*': {
        build: false
      },
      'esri-mods': {
        build: false
      },
      'dojo/*': {
        build: false
      },
    }
  });
})(this);

0 个答案:

没有答案