Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tools/gulp): add html minifying task to generated docs #3476

Merged
merged 2 commits into from
Mar 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion tools/gulp/tasks/docs.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import {task, src, dest} from 'gulp';
import {Dgeni} from 'dgeni';
import * as path from 'path';
import {HTML_MINIFIER_OPTIONS} from '../constants';

// Node packages that lack of types.
const markdown = require('gulp-markdown');
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');
const dom = require('gulp-dom');

Expand Down Expand Up @@ -42,7 +44,7 @@ const MARKDOWN_TAGS_TO_CLASS_ALIAS = [
'ul'
];

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 @@ -83,6 +85,12 @@ task('api-docs', () => {
return docs.generate();
});

task('minify-html-docs', ['api-docs'], () => {
return src('dist/docs/api/*.html')
.pipe(htmlmin(HTML_MINIFIER_OPTIONS))
.pipe(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