source: trip-planner-front/node_modules/@angular-devkit/build-angular/src/utils/index-file/inline-critical-css.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.9 KB
Line 
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.io/license
8 */
9var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10 if (k2 === undefined) k2 = k;
11 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12}) : (function(o, m, k, k2) {
13 if (k2 === undefined) k2 = k;
14 o[k2] = m[k];
15}));
16var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17 Object.defineProperty(o, "default", { enumerable: true, value: v });
18}) : function(o, v) {
19 o["default"] = v;
20});
21var __importStar = (this && this.__importStar) || function (mod) {
22 if (mod && mod.__esModule) return mod;
23 var result = {};
24 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25 __setModuleDefault(result, mod);
26 return result;
27};
28Object.defineProperty(exports, "__esModule", { value: true });
29exports.InlineCriticalCssProcessor = void 0;
30const fs = __importStar(require("fs"));
31const Critters = require('critters');
32class CrittersExtended extends Critters {
33 constructor(optionsExtended) {
34 super({
35 logger: {
36 warn: (s) => this.warnings.push(s),
37 error: (s) => this.errors.push(s),
38 info: () => { },
39 },
40 logLevel: 'warn',
41 path: optionsExtended.outputPath,
42 publicPath: optionsExtended.deployUrl,
43 compress: !!optionsExtended.minify,
44 pruneSource: false,
45 reduceInlineStyles: false,
46 mergeStylesheets: false,
47 preload: 'media',
48 noscriptFallback: true,
49 inlineFonts: true,
50 });
51 this.optionsExtended = optionsExtended;
52 this.warnings = [];
53 this.errors = [];
54 }
55 readFile(path) {
56 const readAsset = this.optionsExtended.readAsset;
57 return readAsset ? readAsset(path) : fs.promises.readFile(path, 'utf-8');
58 }
59}
60class InlineCriticalCssProcessor {
61 constructor(options) {
62 this.options = options;
63 }
64 async process(html, options) {
65 const critters = new CrittersExtended({ ...this.options, ...options });
66 const content = await critters.process(html);
67 return {
68 // Clean up value from value less attributes.
69 // This is caused because parse5 always requires attributes to have a string value.
70 // nomodule="" defer="" -> nomodule defer.
71 content: content.replace(/(\s(?:defer|nomodule))=""/g, '$1'),
72 errors: critters.errors,
73 warnings: critters.warnings,
74 };
75 }
76}
77exports.InlineCriticalCssProcessor = InlineCriticalCssProcessor;
Note: See TracBrowser for help on using the repository browser.