xref: /expo/packages/@expo/cli/src/export/html.ts (revision 2101e951)
1// <link rel="preload" href="/_expo/static/css/xxxxxx.css" as="style">
2export function appendLinkToHtml(
3  html: string,
4  links: { rel: string; href: string; as?: string }[]
5) {
6  return html.replace(
7    '</head>',
8    links
9      .map((link) => {
10        let linkTag = `<link rel="${link.rel}"`;
11
12        if (link.href) linkTag += ` href="${link.href}"`;
13        if (link.as) linkTag += ` as="${link.as}"`;
14
15        linkTag += '>';
16
17        return linkTag;
18      })
19      .join('') + '</head>'
20  );
21}
22
23export function appendScriptsToHtml(html: string, scripts: string[]) {
24  return html.replace(
25    '</body>',
26    scripts.map((script) => `<script src="${script}" defer></script>`).join('') + '</body>'
27  );
28}
29