1- import { task , watch } from 'gulp' ;
1+ import { task , watch , src , dest } from 'gulp' ;
22import { join } from 'path' ;
33import { main as tsc } from '@angular/tsc-wrapped' ;
4- import { SOURCE_ROOT , DIST_ROOT } from '../build-config' ;
4+ import { SOURCE_ROOT , DIST_ROOT , HTML_MINIFIER_OPTIONS } from '../build-config' ;
55import { sequenceTask , sassBuildTask , copyTask , triggerLivereload } from '../util/task_helpers' ;
66import { composeRelease } from './build-release' ;
77import { buildPackageBundles } from './build-bundles' ;
88
99// There are no type definitions available for these imports.
1010const inlineResources = require ( '../../../scripts/release/inline-resources' ) ;
11+ const htmlmin = require ( 'gulp-htmlmin' ) ;
1112
1213/**
1314 * Creates a set of gulp tasks that can build the specified package.
@@ -25,8 +26,11 @@ export function createPackageBuildTasks(packageName: string, requiredPackages: s
2526 // Paths to the different output files and directories.
2627 const esmMainFile = join ( packageOut , 'index.js' ) ;
2728
28- // Glob that matches all assets that should be copied to the package.
29- const assetsGlob = join ( packageRoot , '**/*.+(html|scss|css)' ) ;
29+ // Glob that matches all style files that need to be copied to the package output.
30+ const stylesGlob = join ( packageRoot , '**/*.+(scss|css)' ) ;
31+
32+ // Glob that matches every HTML file in the current package.
33+ const htmlGlob = join ( packageRoot , '**/*.html' ) ;
3034
3135 /**
3236 * Main tasks for the package building. Tasks execute the different sub-tasks in the correct
@@ -70,10 +74,16 @@ export function createPackageBuildTasks(packageName: string, requiredPackages: s
7074 /**
7175 * Asset tasks. Building SASS files and inlining CSS, HTML files into the ESM output.
7276 */
73- task ( `${ packageName } :assets` , [ `${ packageName } :assets:scss` , `${ packageName } :assets:html` ] ) ;
77+ task ( `${ packageName } :assets` , [
78+ `${ packageName } :assets:scss` , `${ packageName } :assets:copy-styles` , `${ packageName } :assets:html`
79+ ] ) ;
7480
7581 task ( `${ packageName } :assets:scss` , sassBuildTask ( packageOut , packageRoot , true ) ) ;
76- task ( `${ packageName } :assets:html` , copyTask ( assetsGlob , packageOut ) ) ;
82+ task ( `${ packageName } :assets:copy-styles` , copyTask ( stylesGlob , packageOut ) ) ;
83+ task ( `${ packageName } :assets:html` , ( ) => {
84+ return src ( htmlGlob ) . pipe ( htmlmin ( HTML_MINIFIER_OPTIONS ) ) . pipe ( dest ( packageOut ) ) ;
85+ } ) ;
86+
7787 task ( `${ packageName } :assets:inline` , ( ) => inlineResources ( packageOut ) ) ;
7888
7989 /**
0 commit comments