redoc/build/tasks/build.js

55 lines
1.4 KiB
JavaScript
Raw Normal View History

2015-10-03 11:54:09 +03:00
var gulp = require('gulp');
var runSequence = require('run-sequence');
var Builder = require('systemjs-builder');
var inlineNg2Template = require('gulp-inline-ng2-template');
2015-10-03 11:54:09 +03:00
var path = require('path');
2015-10-14 23:59:39 +03:00
var sourcemaps = require('gulp-sourcemaps');
2015-10-03 11:54:09 +03:00
var paths = require('../paths');
var fs= require('fs');
2015-10-14 23:59:39 +03:00
var concat = require('gulp-concat');
2015-10-03 11:54:09 +03:00
2015-10-14 23:59:39 +03:00
paths.redocBuilt = path.join(paths.output, paths.outputName);
2015-10-03 11:54:09 +03:00
gulp.task('build', function (callback) {
return runSequence(
'clean',
2015-10-14 23:59:39 +03:00
'bundle',
2015-10-03 11:54:09 +03:00
callback
);
});
2015-10-14 23:59:39 +03:00
gulp.task('bundle', ['bundleSfx', 'concatDeps']);
gulp.task('inlineTemplates', function() {
return gulp.src(paths.source, { base: './' })
.pipe(inlineNg2Template({ base: '/' }))
.pipe(gulp.dest(paths.tmp));
});
2015-10-14 23:59:39 +03:00
var JS_DEV_DEPS = [
'node_modules/zone.js/dist/zone-microtask.js'
];
// concatenate angular2 deps
gulp.task('concatDeps', ['bundleSfx'], function() {
gulp.src(JS_DEV_DEPS.concat([paths.redocBuilt]))
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(concat(paths.outputName))
.pipe(sourcemaps.write())
.pipe(gulp.dest(paths.output))
});
gulp.task('bundleSfx', ['inlineTemplates'], function(cb) {
2015-10-03 11:54:09 +03:00
var builder = new Builder('./', 'system.config.js');
builder
.buildStatic(path.join(paths.tmp, paths.sourceEntryPoint),
2015-10-14 23:59:39 +03:00
paths.redocBuilt,
2015-10-07 10:18:02 +03:00
{ globalName: 'Redoc', sourceMaps: true }
)
2015-10-03 11:54:09 +03:00
.then(function() {
cb();
})
.catch(function(err) {
cb(new Error(err));
});
});