Skip to content

Commit c31a0ac

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

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tools/gulp/tasks/docs.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const transform = require('gulp-transform');
88
const highlight = require('gulp-highlight-files');
99
const rename = require('gulp-rename');
1010
const flatten = require('gulp-flatten');
11+
const htmlmin = require('gulp-htmlmin');
1112
const hljs = require('highlight.js');
1213

1314
// Our docs contain comments of the form `<!-- example(...) -->` which serve as placeholders where
@@ -21,7 +22,7 @@ const EXAMPLE_PATTERN = /<!--\W*example\(([^)]+)\)\W*-->/g;
2122
// documentation page. Using a RegExp to rewrite links in HTML files to work in the docs.
2223
const LINK_PATTERN = /(<a[^>]*) href="([^"]*)"/g;
2324

24-
task('docs', ['markdown-docs', 'highlight-docs', 'api-docs']);
25+
gulp.task('docs', ['markdown-docs', 'highlight-docs', 'api-docs', 'minify-html-docs']);
2526

2627
task('markdown-docs', () => {
2728
return src(['src/lib/**/*.md', 'guides/*.md'])
@@ -61,6 +62,12 @@ task('api-docs', () => {
6162
return docs.generate();
6263
});
6364

65+
task('minify-html-docs', ['api-docs'], () => {
66+
return gulp.src('dist/docs/api/*.html')
67+
.pipe(htmlmin({collapseWhitespace: true}))
68+
.pipe(gulp.dest('dist/docs/api/'));
69+
});
70+
6471
/** Updates the markdown file's content to work inside of the docs app. */
6572
function transformMarkdownFiles(buffer: Buffer, file: any): string {
6673
let content = buffer.toString('utf-8');

0 commit comments

Comments
 (0)