diff --git a/packages/astro/src/build/bundle/css.ts b/packages/astro/src/build/bundle/css.ts index e585ce393..e2911f94b 100644 --- a/packages/astro/src/build/bundle/css.ts +++ b/packages/astro/src/build/bundle/css.ts @@ -124,31 +124,30 @@ export async function bundleCSS({ const newHref = cssMap.get(oldHref); if (!newHref) { - return + return; } if (el.attribs?.rel === 'preload') { if (preloads.has(newHref)) { $(el).remove(); } else { - $(el).attr("href", cssHashes.get(newHref) || ""); + $(el).attr('href', cssHashes.get(newHref) || ''); preloads.add(newHref); } - return + return; } if (stylesheets.has(newHref)) { $(el).remove(); // this is a dupe; remove } else { - $(el).attr("href", cssHashes.get(newHref) || ""); // new CSS; update href (important! use cssHashes, not cssMap) + $(el).attr('href', cssHashes.get(newHref) || ''); // new CSS; update href (important! use cssHashes, not cssMap) // bonus: add [rel] and [type]. not necessary, but why not? - $(el).attr("rel", "stylesheet"); - $(el).attr("type", "text/css"); + $(el).attr('rel', 'stylesheet'); + $(el).attr('type', 'text/css'); stylesheets.add(newHref); } - }); (buildState[id] as any).contents = $.html(); // save updated HTML in global buildState }) diff --git a/packages/astro/test/astro-css-bundling.test.js b/packages/astro/test/astro-css-bundling.test.js index a69fb69dd..2ae4db91f 100644 --- a/packages/astro/test/astro-css-bundling.test.js +++ b/packages/astro/test/astro-css-bundling.test.js @@ -14,7 +14,7 @@ const EXPECTED_CSS = { '/one/index.html': ['/_astro/common-', '/_astro/one/index-'], '/two/index.html': ['/_astro/common-', '/_astro/two/index-'], '/preload/index.html': ['/_astro/common-', '/_astro/preload/index-'], - '/preload-merge/index.html': ['/_astro/preload-merge/index-'] + '/preload-merge/index.html': ['/_astro/preload-merge/index-'], }; const UNEXPECTED_CSS = ['/_astro/components/nav.css', '../css/typography.css', '../css/colors.css', '../css/page-index.css', '../css/page-one.css', '../css/page-two.css'];