blob: 212034a2675be7fe073dc704b8cd1095c05633a1 [file] [log] [blame]
Steven Burrowsa145e102017-06-16 13:37:50 -04001import gulp from 'gulp';
2import concat from 'gulp-concat';
3import strip from 'gulp-strip-comments';
4import uglyfy from 'gulp-uglify';
5import sourceMaps from 'gulp-sourcemaps';
6import BundleResources from '../helpers/bundleResources';
7
8
9const GUI_BASE = '../../web/gui/src/main/webapp/';
10const bundleFiles = [
11 // NOTE: Bundle the important files first
12 'app/directives.js',
13 'app/fw/util/util.js',
14 'app/fw/mast/mast.js',
15 'app/fw/nav/nav.js',
16 'app/fw/svg/svg.js',
17 'app/fw/remote/remote.js',
18 'app/fw/widget/widget.js',
19 'app/fw/layer/layer.js',
20
21 // NOTE: bundle everything else
22 'app/fw/**/*.js',
23 'app/view/**/*.js'
24];
25
26const vendor = [
27 'tp/angular.js',
28 'tp/angular-route.js',
29 'tp/angular-cookies.js',
30 'tp/d3.js',
31 'tp/topojson.v1.min.js',
Steven Burrows96ee21e2017-07-11 19:49:45 +010032 'tp/Chart.js',
Steven Burrowsa145e102017-06-16 13:37:50 -040033 'tp/lodash.min.js',
34];
35
36function bundle(files, exportName) {
37 return gulp.src(BundleResources(GUI_BASE, files))
38 .pipe(sourceMaps.init())
39 .pipe(strip())
40 .pipe(uglyfy())
Steven Burrowsdc165622017-07-20 14:40:27 +010041 .on('error', (e, file, line) => console.error(e))
Steven Burrowsa145e102017-06-16 13:37:50 -040042 .pipe(concat(exportName))
43 .pipe(sourceMaps.write('source-map'))
44 .pipe(gulp.dest(GUI_BASE + '/dist/'));
45}
46
47const tasks = function () {
48 gulp.task('bundle-vendor', () => bundle(vendor, 'vendor.js'));
49 gulp.task('bundle-js', () => bundle(bundleFiles, 'onos.js'));
50};
51
52export default tasks();