11import { task , src , dest } from 'gulp' ;
22import { Dgeni } from 'dgeni' ;
33import * as path from 'path' ;
4+ import { HTML_MINIFIER_OPTIONS } from '../constants' ;
45
56// Node packages that lack of types.
67const markdown = require ( 'gulp-markdown' ) ;
78const transform = require ( 'gulp-transform' ) ;
89const highlight = require ( 'gulp-highlight-files' ) ;
910const rename = require ( 'gulp-rename' ) ;
1011const flatten = require ( 'gulp-flatten' ) ;
12+ const htmlmin = require ( 'gulp-htmlmin' ) ;
1113const hljs = require ( 'highlight.js' ) ;
1214
1315// Our docs contain comments of the form `<!-- example(...) -->` which serve as placeholders where
@@ -21,7 +23,7 @@ const EXAMPLE_PATTERN = /<!--\W*example\(([^)]+)\)\W*-->/g;
2123// documentation page. Using a RegExp to rewrite links in HTML files to work in the docs.
2224const LINK_PATTERN = / ( < a [ ^ > ] * ) h r e f = " ( [ ^ " ] * ) " / g;
2325
24- task ( 'docs' , [ 'markdown-docs' , 'highlight-docs' , 'api-docs' ] ) ;
26+ task ( 'docs' , [ 'markdown-docs' , 'highlight-docs' , 'api-docs' , 'minify-html-docs' ] ) ;
2527
2628task ( 'markdown-docs' , ( ) => {
2729 return src ( [ 'src/lib/**/*.md' , 'guides/*.md' ] )
@@ -61,6 +63,12 @@ task('api-docs', () => {
6163 return docs . generate ( ) ;
6264} ) ;
6365
66+ task ( 'minify-html-docs' , [ 'api-docs' ] , ( ) => {
67+ return src ( 'dist/docs/api/*.html' )
68+ . pipe ( htmlmin ( HTML_MINIFIER_OPTIONS ) )
69+ . pipe ( dest ( 'dist/docs/api/' ) ) ;
70+ } ) ;
71+
6472/** Updates the markdown file's content to work inside of the docs app. */
6573function transformMarkdownFiles ( buffer : Buffer , file : any ) : string {
6674 let content = buffer . toString ( 'utf-8' ) ;
0 commit comments