material-fonts.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. /**
  3. * @license
  4. * Copyright Google LLC All Rights Reserved.
  5. *
  6. * Use of this source code is governed by an MIT-style license that can be
  7. * found in the LICENSE file at https://angular.dev/license
  8. */
  9. Object.defineProperty(exports, "__esModule", { value: true });
  10. exports.addFontsToIndex = addFontsToIndex;
  11. const schematics_1 = require("@angular-devkit/schematics");
  12. const schematics_2 = require("@angular/cdk/schematics");
  13. const workspace_1 = require("@schematics/angular/utility/workspace");
  14. /** Adds the Material Design fonts to the index HTML file. */
  15. function addFontsToIndex(options) {
  16. return async (host) => {
  17. const workspace = await (0, workspace_1.getWorkspace)(host);
  18. const project = (0, schematics_2.getProjectFromWorkspace)(workspace, options.project);
  19. const projectIndexFiles = (0, schematics_2.getProjectIndexFiles)(project);
  20. if (!projectIndexFiles.length) {
  21. throw new schematics_1.SchematicsException('No project index HTML file could be found.');
  22. }
  23. const fonts = [
  24. 'https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap',
  25. 'https://fonts.googleapis.com/icon?family=Material+Icons',
  26. ];
  27. projectIndexFiles.forEach(indexFilePath => {
  28. fonts.forEach(font => {
  29. (0, schematics_2.appendHtmlElementToHead)(host, indexFilePath, `<link href="${font}" rel="stylesheet">`);
  30. });
  31. });
  32. };
  33. }
  34. //# sourceMappingURL=material-fonts.js.map