SystemJs配置在一个别名下映射多个文件

时间:2018-06-15 18:20:19

标签: javascript gulp systemjs systemjs-builder

我正在尝试找到一种方法将导入模块的依赖项映射到我的应用程序的bundle配置和进程中。依赖别名不能以这种方式工作,而是跳跃来实现这样的事情。我可以简单地对它自己进行每次依赖,但每次我都必须更新gulp任务并希望尽可能地保持这种简化。

SystemJs配置

        paths: {
            'npm:': 'node_modules/',
        },         
        map: {
            // our app is within the build folder
            app : 'build/out-tsc/src',
            // angular bundles
            'text': 'npm:systemjs-plugin-text/text.js',
            '@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
            '@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/common/http': 'npm:@angular/common/bundles/common-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',
            'lodash': 'npm:lodash',
            'tslib': 'npm:tslib/tslib.js',
            // dependencies
            'dependencies': ['npm:underscore/underscore.js', 'npm:moment/moment.js']
        },

Gulp任务:

    var builder = new Builder('', 'systemjs.config.js');
    return builder.bundle('app - [src/*] + dependencies', 'dist/main.js', {
    minify: true,
    mangle: true,
    sourceMaps: 'inline',
    format: 'system'

0 个答案:

没有答案