Last active
December 5, 2016 17:21
-
-
Save kutyel/4679e9cea143e8bed9b148487953704d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Configuración de SystemJS para Angular 2 | |
*/ | |
(function(global) { | |
// el map le dice a System dónde buscar las cosas que ha de cargar | |
var map = { | |
'app': 'app', // 'dist', | |
'@angular': 'node_modules/@angular', | |
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api', | |
'rxjs': 'node_modules/rxjs' | |
}; | |
// los packages le dicen a System cómo cargar un fichero cuando no tiene nombre/extensión | |
var packages = { | |
'app': { main: 'main.js', defaultExtension: 'js' }, | |
'rxjs': { defaultExtension: 'js' }, | |
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' }, | |
}; | |
var ngPackageNames = [ | |
'common', | |
'compiler', | |
'core', | |
'http', | |
'platform-browser', | |
'platform-browser-dynamic', | |
'router', | |
'router-deprecated', | |
'upgrade', | |
]; | |
// Ficheros individuales (te ahorras unas ~300 requests): | |
function packIndex(pkgName) { | |
packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' }; | |
} | |
// Encapsulados (~40 requests): | |
function packUmd(pkgName) { | |
packages['@angular/'+pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' }; | |
} | |
// La mayoría de los entornos deberían usar UMD, algunos (Karma) necesitan ficheros index individuales | |
var setPackageConfig = System.packageWithIndex ? packIndex : packUmd; | |
// Añadir entrada para packages de angular | |
ngPackageNames.forEach(setPackageConfig); | |
var config = { | |
map: map, | |
packages: packages | |
}; | |
System.config(config); | |
})(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can I use this system.config.js with a angular 2 final release or not