Skip to content

Commit

Permalink
chore(tools/gulp): add html minifying task to generated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
riavalon committed Mar 7, 2017
1 parent d78a370 commit 995cc0a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tools/gulp/tasks/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const transform = require('gulp-transform');
const highlight = require('gulp-highlight-files');
const rename = require('gulp-rename');
const flatten = require('gulp-flatten');
const htmlmin = require('gulp-htmlmin');
const hljs = require('highlight.js');

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

task('docs', ['markdown-docs', 'highlight-docs', 'api-docs']);
task('docs', ['markdown-docs', 'highlight-docs', 'api-docs', 'minify-html-docs']);

task('markdown-docs', () => {
return src(['src/lib/**/*.md', 'guides/*.md'])
Expand Down Expand Up @@ -61,6 +62,12 @@ task('api-docs', () => {
return docs.generate();
});

task('minify-html-docs', ['api-docs'], () => {
return gulp.src('dist/docs/api/*.html')
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('dist/docs/api/'));
});

/** Updates the markdown file's content to work inside of the docs app. */
function transformMarkdownFiles(buffer: Buffer, file: any): string {
let content = buffer.toString('utf-8');
Expand Down

0 comments on commit 995cc0a

Please sign in to comment.