-
Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathtransforms.ts
38 lines (31 loc) · 1.13 KB
/
transforms.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { BuildBrowserFeatures } from '../build-browser-features';
import { NormalizeOptimizationOptions } from '../normalize-optimization';
import { InlineFontsProcessor } from './inline-fonts';
import { IndexHtmlTransform } from './write-index-html';
export function getHtmlTransforms(
optimization: NormalizeOptimizationOptions,
buildBrowserFeatures: BuildBrowserFeatures,
extraHtmlTransform?: IndexHtmlTransform,
): IndexHtmlTransform[] {
const indexTransforms: IndexHtmlTransform[] = [];
const { fonts, styles } = optimization;
// Inline fonts
if (fonts.inline) {
const inlineFontsProcessor = new InlineFontsProcessor({
minifyInlinedCSS: styles,
WOFFSupportNeeded: !buildBrowserFeatures.isFeatureSupported('woff2'),
});
indexTransforms.push(content => inlineFontsProcessor.process(content));
}
if (extraHtmlTransform) {
indexTransforms.push(extraHtmlTransform);
}
return indexTransforms;
}