Skip to content

Commit a25ab58

Browse files
committed
chore(docs): minify markdown files
* Right now, only the API HTML files will be minified. The markdown files like guides, and overview HTML files can be minified as well.
1 parent c3d7cd9 commit a25ab58

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

tools/gulp/tasks/docs.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {task, src, dest} from 'gulp';
22
import {Dgeni} from 'dgeni';
33
import * as path from 'path';
4-
import {buildConfig} from 'material2-build-tools';
4+
import {buildConfig, sequenceTask} from 'material2-build-tools';
55
import {apiDocsPackage} from '../../dgeni/index';
66

77
// There are no type definitions available for these imports.
@@ -73,18 +73,21 @@ const markdownOptions = {
7373
};
7474

7575
/** Generate all docs content. */
76-
task('docs', [
77-
'markdown-docs',
78-
'markdown-docs-cdk',
79-
'highlight-examples',
80-
'api-docs',
81-
'minified-api-docs',
82-
'build-examples-module',
83-
'stackblitz-example-assets',
84-
]);
76+
task('docs', sequenceTask(
77+
'clean',
78+
[
79+
'markdown-docs-material',
80+
'markdown-docs-cdk',
81+
'build-highlighted-examples',
82+
'build-examples-module',
83+
'api-docs',
84+
'copy-stackblitz-examples'
85+
],
86+
'minify-html-files'
87+
));
8588

8689
/** Generates html files from the markdown overviews and guides for material. */
87-
task('markdown-docs', () => {
90+
task('markdown-docs-material', () => {
8891
// Extend the renderer for custom heading anchor rendering
8992
markdown.marked.Renderer.prototype.heading = (text: string, level: number): string => {
9093
if (level === 3 || level === 4) {
@@ -124,7 +127,7 @@ task('markdown-docs-cdk', () => {
124127
* Creates syntax-highlighted html files from the examples to be used for the source view of
125128
* live examples on the docs site.
126129
*/
127-
task('highlight-examples', () => {
130+
task('build-highlighted-examples', () => {
128131
// rename files to fit format: [filename]-[filetype].html
129132
const renameFile = (filePath: any) => {
130133
const extension = filePath.extname.slice(1);
@@ -144,15 +147,18 @@ task('api-docs', () => {
144147
return docs.generate();
145148
});
146149

147-
/** Generates minified html api docs. */
148-
task('minified-api-docs', ['api-docs'], () => {
149-
return src('dist/docs/api/*.html')
150+
/**
151+
* Minifies all HTML files that have been generated. The HTML files for the
152+
* highlighted examples can be skipped, because it won't have any effect.
153+
*/
154+
task('minify-html-files', ['api-docs'], () => {
155+
return src('dist/docs/+(api|markdown)/**/*.html')
150156
.pipe(htmlmin(htmlMinifierOptions))
151-
.pipe(dest('dist/docs/api/'));
157+
.pipe(dest('dist/docs'));
152158
});
153159

154160
/** Copies example sources to be used as stackblitz assets for the docs site. */
155-
task('stackblitz-example-assets', () => {
161+
task('copy-stackblitz-examples', () => {
156162
src(path.join(packagesDir, 'material-examples', '**/*'))
157163
.pipe(dest(path.join(DIST_DOCS, 'stackblitz', 'examples')));
158164
});

0 commit comments

Comments
 (0)