forked from alenny/angular2-adal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbundle.js
66 lines (61 loc) · 1.89 KB
/
bundle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const gulp = require('gulp');
const config = require('./config');
const path = require('path');
const $ = require('gulp-load-plugins')();
const Builder = require('systemjs-builder');
const bundleConfig = {
baseURL: config.PATHS.dist.cjs,
defaultJSExtensions: true,
packageConfigPaths: [
path.join('.', 'node_modules', '*', 'package.json'),
path.join('.', 'node_modules', '@angular', '*', 'package.json')
],
paths: {
'angular2-adal/*': '*',
'@angular/*': './node_modules/@angular/*',
'adal.js': './node_modules/adal-angular/lib/adal.js',
'*': './node_modules/*'
},
packages: {
'@angular/core': {
main: 'index.js',
defaultExtension: 'js'
},
'@angular/compiler': {
main: 'index.js',
defaultExtension: 'js'
},
'@angular/common': {
main: 'index.js',
defaultExtension: 'js'
},
'@angular/platform-browser': {
main: 'index.js',
defaultExtension: 'js'
},
rxjs: {
main: 'Rx.js',
defaultExtension: 'js'
}
}
};
function bundle(moduleName, moduleBundleName, minify, done) {
const outputConfig = {
sourceMaps: true, minify
};
const builder = new Builder(bundleConfig);
const outputFile =
path.join(config.PATHS.dist.bundles, `${moduleBundleName}${(minify ? '.min' : '')}.js`);
const bundlePromise =
builder.bundle(`${moduleName}`, outputFile, outputConfig);
return bundlePromise.then(() => {
done();
});
}
gulp.task('bundle:cjs', ['scripts:cjs'], (done) => {
bundle('angular2-adal/core', 'angular2-adal', false, done);
});
gulp.task('bundle:cjs:min', ['scripts:cjs'], (done) => {
bundle('angular2-adal/core', 'angular2-adal', true, done);
});
gulp.task('bundle', ['bundle:cjs', 'bundle:cjs:min']);