Build minified version

This commit is contained in:
Roman Hotsiy 2016-01-06 17:21:33 +02:00
parent dbfc9fe4a0
commit d7fac00ae4
2 changed files with 16 additions and 4 deletions

View File

@ -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/**/*',

View File

@ -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))
});