Skip to content

Commit 0f11b24

Browse files
committed
chore(tools/gulp): add html minifying task to generated docs
1 parent d78a370 commit 0f11b24

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tools/gulp/tasks/docs.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import {task, src, dest} from 'gulp';
22
import {Dgeni} from 'dgeni';
33
import * as path from 'path';
4+
import {HTML_MINIFIER_OPTIONS} from '../constants';
45

56
// Node packages that lack of types.
67
const markdown = require('gulp-markdown');
78
const transform = require('gulp-transform');
89
const highlight = require('gulp-highlight-files');
910
const rename = require('gulp-rename');
1011
const flatten = require('gulp-flatten');
12+
const htmlmin = require('gulp-htmlmin');
1113
const 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.
2224
const LINK_PATTERN = /(<a[^>]*) href="([^"]*)"/g;
2325

24-
task('docs', ['markdown-docs', 'highlight-docs', 'api-docs']);
26+
task('docs', ['markdown-docs', 'highlight-docs', 'api-docs', 'minify-html-docs']);
2527

2628
task('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. */
6573
function transformMarkdownFiles(buffer: Buffer, file: any): string {
6674
let content = buffer.toString('utf-8');

0 commit comments

Comments
 (0)