Skip to content

Commit cdb3763

Browse files
riavalontinayuangao
authored andcommitted
chore(tools/gulp): add html minifying task to generated docs (angular#3476)
1 parent ee853b9 commit cdb3763

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
const dom = require('gulp-dom');
1315

@@ -42,7 +44,7 @@ const MARKDOWN_TAGS_TO_CLASS_ALIAS = [
4244
'ul'
4345
];
4446

45-
task('docs', ['markdown-docs', 'highlight-docs', 'api-docs']);
47+
task('docs', ['markdown-docs', 'highlight-docs', 'api-docs', 'minify-html-docs']);
4648

4749
task('markdown-docs', () => {
4850
return src(['src/lib/**/*.md', 'guides/*.md'])
@@ -83,6 +85,12 @@ task('api-docs', () => {
8385
return docs.generate();
8486
});
8587

88+
task('minify-html-docs', ['api-docs'], () => {
89+
return src('dist/docs/api/*.html')
90+
.pipe(htmlmin(HTML_MINIFIER_OPTIONS))
91+
.pipe(dest('dist/docs/api/'));
92+
});
93+
8694
/** Updates the markdown file's content to work inside of the docs app. */
8795
function transformMarkdownFiles(buffer: Buffer, file: any): string {
8896
let content = buffer.toString('utf-8');

0 commit comments

Comments
 (0)