File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
src/material/schematics/ng-add Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -26,12 +26,20 @@ export function addFontsToIndex(options: Schema): Rule {
2626 throw new SchematicsException ( 'No project index HTML file could be found.' ) ;
2727 }
2828
29+ const preconnectLinks = [
30+ '<link rel="preconnect" href="https://fonts.googleapis.com">' ,
31+ '<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>' ,
32+ ] ;
33+
2934 const fonts = [
3035 'https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap' ,
3136 'https://fonts.googleapis.com/icon?family=Material+Icons' ,
3237 ] ;
3338
3439 projectIndexFiles . forEach ( indexFilePath => {
40+ preconnectLinks . forEach ( link => {
41+ appendHtmlElementToHead ( host , indexFilePath , link ) ;
42+ } ) ;
3543 fonts . forEach ( font => {
3644 appendHtmlElementToHead ( host , indexFilePath , `<link href="${ font } " rel="stylesheet">` ) ;
3745 } ) ;
Original file line number Diff line number Diff line change @@ -144,6 +144,12 @@ describe('ng-add schematic', () => {
144144 // Ensure that the indentation has been determined properly. We want to make sure that
145145 // the created links properly align with the existing HTML. Default CLI projects use an
146146 // indentation of two columns.
147+ expect ( htmlContent ) . toContain (
148+ ' <link rel="preconnect" href="https://fonts.googleapis.com">' ,
149+ ) ;
150+ expect ( htmlContent ) . toContain (
151+ ' <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>' ,
152+ ) ;
147153 expect ( htmlContent ) . toContain (
148154 ' <link href="https://fonts.googleapis.com/icon?family=Material+Icons"' ,
149155 ) ;
You can’t perform that action at this time.
0 commit comments