From d7fac00ae4bc8a63471864f664698ddb8312c063 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 6 Jan 2016 17:21:33 +0200 Subject: [PATCH] Build minified version --- build/paths.js | 2 +- build/tasks/build.js | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/build/paths.js b/build/paths.js index b78fe559..c780902c 100644 --- a/build/paths.js +++ b/build/paths.js @@ -3,7 +3,7 @@ module.exports = { html: 'lib/**/*.html', scss: 'lib/**/*.scss', sourceEntryPoint: 'lib/index.js', - outputName: 'redoc.full.js', + outputName: 'redoc.full', output: 'dist/', tmp: '.tmp/', demo: 'demo/**/*', diff --git a/build/tasks/build.js b/build/tasks/build.js index a9eed6c0..c37fc467 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -10,8 +10,10 @@ var concat = require('gulp-concat'); var gulp = require('gulp'); var sass = require('gulp-sass'); var replace = require('gulp-replace'); +var uglify = require('gulp-uglify'); +var rename = require('gulp-rename'); -paths.redocBuilt = path.join(paths.output, paths.outputName); +paths.redocBuilt = path.join(paths.output, paths.outputName) + '.js'; gulp.task('build', function (callback) { return runSequence( 'clean', @@ -20,7 +22,7 @@ gulp.task('build', function (callback) { ); }); -gulp.task('bundle', ['bundleSfx', 'concatDeps']); +gulp.task('bundle', ['bundleSfx', 'concatDeps', 'uglify']); gulp.task('inlineTemplates', ['sass'], function() { return gulp.src(paths.source, { base: './' }) @@ -29,6 +31,16 @@ gulp.task('inlineTemplates', ['sass'], function() { .pipe(gulp.dest(paths.tmp)); }); +// produces minimized verstion of sfx bundle +gulp.task('uglify', ['concatDeps'], function() { + return gulp.src(paths.redocBuilt) + .pipe(sourcemaps.init()) + .pipe(uglify()) + .pipe(rename(paths.outputName + '.min.js')) + .pipe(sourcemaps.write('./')) + .pipe(gulp.dest(paths.output)); +}); + var JS_DEV_DEPS = [ 'node_modules/zone.js/dist/zone-microtask.js', 'node_modules/reflect-metadata/Reflect.js' @@ -44,7 +56,7 @@ gulp.task('sass', function () { gulp.task('concatDeps', ['bundleSfx'], function() { gulp.src(JS_DEV_DEPS.concat([paths.redocBuilt])) .pipe(sourcemaps.init({loadMaps: true})) - .pipe(concat(paths.outputName)) + .pipe(concat(paths.outputName + '.js')) .pipe(sourcemaps.write('.')) .pipe(gulp.dest(paths.output)) });