1
1
import { task , src , dest } from 'gulp' ;
2
2
import { Dgeni } from 'dgeni' ;
3
3
import * as path from 'path' ;
4
+ import { HTML_MINIFIER_OPTIONS } from '../constants' ;
4
5
5
6
// Node packages that lack of types.
6
7
const markdown = require ( 'gulp-markdown' ) ;
7
8
const transform = require ( 'gulp-transform' ) ;
8
9
const highlight = require ( 'gulp-highlight-files' ) ;
9
10
const rename = require ( 'gulp-rename' ) ;
10
11
const flatten = require ( 'gulp-flatten' ) ;
12
+ const htmlmin = require ( 'gulp-htmlmin' ) ;
11
13
const hljs = require ( 'highlight.js' ) ;
12
14
13
15
// Our docs contain comments of the form `<!-- example(...) -->` which serve as placeholders where
@@ -21,7 +23,7 @@ const EXAMPLE_PATTERN = /<!--\W*example\(([^)]+)\)\W*-->/g;
21
23
// documentation page. Using a RegExp to rewrite links in HTML files to work in the docs.
22
24
const LINK_PATTERN = / ( < a [ ^ > ] * ) h r e f = " ( [ ^ " ] * ) " / g;
23
25
24
- task ( 'docs' , [ 'markdown-docs' , 'highlight-docs' , 'api-docs' ] ) ;
26
+ task ( 'docs' , [ 'markdown-docs' , 'highlight-docs' , 'api-docs' , 'minify-html-docs' ] ) ;
25
27
26
28
task ( 'markdown-docs' , ( ) => {
27
29
return src ( [ 'src/lib/**/*.md' , 'guides/*.md' ] )
@@ -61,6 +63,12 @@ task('api-docs', () => {
61
63
return docs . generate ( ) ;
62
64
} ) ;
63
65
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
+
64
72
/** Updates the markdown file's content to work inside of the docs app. */
65
73
function transformMarkdownFiles ( buffer : Buffer , file : any ) : string {
66
74
let content = buffer . toString ( 'utf-8' ) ;
0 commit comments