1
- import { task , watch } from 'gulp' ;
1
+ import { task , watch , src , dest } from 'gulp' ;
2
2
import { join } from 'path' ;
3
3
import { 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' ;
5
5
import { sequenceTask , sassBuildTask , copyTask , triggerLivereload } from '../util/task_helpers' ;
6
6
import { composeRelease } from './build-release' ;
7
7
import { buildPackageBundles } from './build-bundles' ;
8
8
9
9
// There are no type definitions available for these imports.
10
10
const inlineResources = require ( '../../../scripts/release/inline-resources' ) ;
11
+ const htmlmin = require ( 'gulp-htmlmin' ) ;
11
12
12
13
/**
13
14
* Creates a set of gulp tasks that can build the specified package.
@@ -25,8 +26,11 @@ export function createPackageBuildTasks(packageName: string, requiredPackages: s
25
26
// Paths to the different output files and directories.
26
27
const esmMainFile = join ( packageOut , 'index.js' ) ;
27
28
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' ) ;
30
34
31
35
/**
32
36
* 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
70
74
/**
71
75
* Asset tasks. Building SASS files and inlining CSS, HTML files into the ESM output.
72
76
*/
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
+ ] ) ;
74
80
75
81
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
+
77
87
task ( `${ packageName } :assets:inline` , ( ) => inlineResources ( packageOut ) ) ;
78
88
79
89
/**
0 commit comments