MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / inlineStyles

Function inlineStyles

vmm/ui/build.mjs:105–117  ·  view source on GitHub ↗
(html, baseDir)

Source from the content-addressed store, hash-verified

103}
104
105async function inlineStyles(html, baseDir) {
106 const linkRegex = /<link\s+rel=["']stylesheet["']\s+href=["'](.+?)["']\s*\/?>(?:\s*<\/link>)?/gi;
107 let result = html;
108 let match;
109 while ((match = linkRegex.exec(html)) !== null) {
110 const href = match[1];
111 const cssPath = path.resolve(baseDir, href);
112 const cssContent = await fs.readFile(cssPath, 'utf-8');
113 const styleTag = `<style>\n${cssContent}\n</style>`;
114 result = result.replace(match[0], styleTag);
115 }
116 return result;
117}
118
119async function inlineScripts(html, scripts) {
120 let result = html;

Callers 1

buildFunction · 0.85

Calls 1

resolveMethod · 0.80

Tested by

no test coverage detected