UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

1 lines • 2.1 kB
{"version":3,"file":"criticalCSSPlugin.js","names":[],"sources":["esm/vite/plugins/criticalCSSPlugin.js"],"sourcesContent":["import { relative } from \"node:path\";\nimport { normalizePath } from \"vite\";\nconst INLINE_CSS_RE = /\\.inline\\.css$/;\nconst criticalCSSSources = /* @__PURE__ */ new Set();\nlet root = \"\";\nfunction getCriticalCSSSources() {\n return criticalCSSSources;\n}\nfunction getCriticalCSSOutputPaths(clientManifest) {\n const outputPaths = /* @__PURE__ */ new Set();\n for (const [sourceKey, entry] of Object.entries(clientManifest)) {\n if (sourceKey.endsWith(\".css\") && criticalCSSSources.has(sourceKey)) {\n outputPaths.add(`/${entry.file}`);\n }\n }\n return outputPaths;\n}\nfunction criticalCSSPlugin() {\n return {\n name: \"one:critical-css\",\n enforce: \"pre\",\n configResolved(config) {\n root = config.root;\n },\n resolveId: {\n filter: { id: INLINE_CSS_RE },\n async handler(id, importer) {\n const resolved = await this.resolve(id, importer, { skipSelf: true });\n if (resolved) {\n const relativePath = normalizePath(relative(root, resolved.id));\n criticalCSSSources.add(relativePath);\n return resolved;\n }\n return null;\n }\n }\n };\n}\nexport {\n criticalCSSPlugin,\n getCriticalCSSOutputPaths,\n getCriticalCSSSources\n};\n//# sourceMappingURL=criticalCSSPlugin.js.map\n"],"mappings":";;;;AAEA,MAAM,gBAAgB;AACtB,MAAM,qCAAqC,IAAI,IAAI;AACnD,IAAI,OAAO;AACX,SAAS,wBAAwB;CAC/B,OAAO;AACT;AACA,SAAS,0BAA0B,gBAAgB;CACjD,MAAM,8BAA8B,IAAI,IAAI;CAC5C,KAAK,MAAM,CAAC,WAAW,UAAU,OAAO,QAAQ,cAAc,GAAG;EAC/D,IAAI,UAAU,SAAS,MAAM,KAAK,mBAAmB,IAAI,SAAS,GAAG;GACnE,YAAY,IAAI,IAAI,MAAM,MAAM;EAClC;CACF;CACA,OAAO;AACT;AACA,SAAS,oBAAoB;CAC3B,OAAO;EACL,MAAM;EACN,SAAS;EACT,eAAe,QAAQ;GACrB,OAAO,OAAO;EAChB;EACA,WAAW;GACT,QAAQ,EAAE,IAAI,cAAc;GAC5B,MAAM,QAAQ,IAAI,UAAU;IAC1B,MAAM,WAAW,MAAM,KAAK,QAAQ,IAAI,UAAU,EAAE,UAAU,KAAK,CAAC;IACpE,IAAI,UAAU;KACZ,MAAM,eAAe,cAAc,SAAS,MAAM,SAAS,EAAE,CAAC;KAC9D,mBAAmB,IAAI,YAAY;KACnC,OAAO;IACT;IACA,OAAO;GACT;EACF;CACF;AACF"}