From 0f11b248a8ba2d68fc5bc31e5e6122536629c01e Mon Sep 17 00:00:00 2001 From: Raven Avalon Date: Tue, 7 Mar 2017 11:01:37 -0500 Subject: [PATCH] chore(tools/gulp): add html minifying task to generated docs --- tools/gulp/tasks/docs.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/gulp/tasks/docs.ts b/tools/gulp/tasks/docs.ts index 9007f9df2334..a29d4217be37 100644 --- a/tools/gulp/tasks/docs.ts +++ b/tools/gulp/tasks/docs.ts @@ -1,6 +1,7 @@ import {task, src, dest} from 'gulp'; import {Dgeni} from 'dgeni'; import * as path from 'path'; +import {HTML_MINIFIER_OPTIONS} from '../constants'; // Node packages that lack of types. const markdown = require('gulp-markdown'); @@ -8,6 +9,7 @@ const transform = require('gulp-transform'); const highlight = require('gulp-highlight-files'); const rename = require('gulp-rename'); const flatten = require('gulp-flatten'); +const htmlmin = require('gulp-htmlmin'); const hljs = require('highlight.js'); // Our docs contain comments of the form `` which serve as placeholders where @@ -21,7 +23,7 @@ const EXAMPLE_PATTERN = //g; // documentation page. Using a RegExp to rewrite links in HTML files to work in the docs. const LINK_PATTERN = /(]*) href="([^"]*)"/g; -task('docs', ['markdown-docs', 'highlight-docs', 'api-docs']); +task('docs', ['markdown-docs', 'highlight-docs', 'api-docs', 'minify-html-docs']); task('markdown-docs', () => { return src(['src/lib/**/*.md', 'guides/*.md']) @@ -61,6 +63,12 @@ task('api-docs', () => { return docs.generate(); }); +task('minify-html-docs', ['api-docs'], () => { + return src('dist/docs/api/*.html') + .pipe(htmlmin(HTML_MINIFIER_OPTIONS)) + .pipe(dest('dist/docs/api/')); +}); + /** Updates the markdown file's content to work inside of the docs app. */ function transformMarkdownFiles(buffer: Buffer, file: any): string { let content = buffer.toString('utf-8');