Home / Function/ stylesFromStaticOutput() — astro Function Reference

stylesFromStaticOutput() — astro Function Reference

Architecture documentation for the stylesFromStaticOutput() function in css-inline-stylesheets.test.js from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  eb1daa58_a551_91c8_15e7_f142852d2d4f["stylesFromStaticOutput()"]
  69f44a61_9817_7df2_a252_265cbb82c7d7["css-inline-stylesheets.test.js"]
  eb1daa58_a551_91c8_15e7_f142852d2d4f -->|defined in| 69f44a61_9817_7df2_a252_265cbb82c7d7
  style eb1daa58_a551_91c8_15e7_f142852d2d4f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/test/css-inline-stylesheets.test.js lines 257–271

async function stylesFromStaticOutput(fixture) {
	const html = await fixture.readFile('/index.html');
	const $ = cheerio.load(html);

	const links = $('link[rel=stylesheet]');
	const hrefs = links.map((_, linkEl) => linkEl.attribs.href).toArray();
	const allLinkedStylesheets = await Promise.all(hrefs.map((href) => fixture.readFile(href)));
	const allLinkedStyles = allLinkedStylesheets.join('');

	const styles = $('style');
	const allInlinedStylesheets = styles.map((_, styleEl) => styleEl.children[0].data).toArray();
	const allInlinedStyles = allInlinedStylesheets.join('');

	return allLinkedStyles + allInlinedStyles;
}

Subdomains

Frequently Asked Questions

What does stylesFromStaticOutput() do?
stylesFromStaticOutput() is a function in the astro codebase, defined in packages/astro/test/css-inline-stylesheets.test.js.
Where is stylesFromStaticOutput() defined?
stylesFromStaticOutput() is defined in packages/astro/test/css-inline-stylesheets.test.js at line 257.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free