mnfst-render 0.5.21 → 0.5.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/manifest.render.mjs +24 -0
- package/package.json +1 -1
package/manifest.render.mjs
CHANGED
|
@@ -701,6 +701,7 @@ function injectBeforeHeadClose(html, snippet) {
|
|
|
701
701
|
return out.replace(/<\/head>/i, `${snippet}\n</head>`);
|
|
702
702
|
}
|
|
703
703
|
|
|
704
|
+
|
|
704
705
|
function indexHtmlUsesTailwind(rootDir) {
|
|
705
706
|
const indexPath = join(rootDir, 'index.html');
|
|
706
707
|
if (!existsSync(indexPath)) return false;
|
|
@@ -814,6 +815,29 @@ function runTailwindCliForPrerender(rootDir, outputDir, pre) {
|
|
|
814
815
|
console.error('prerender: Tailwind CLI did not produce prerender.tailwind.css');
|
|
815
816
|
return false;
|
|
816
817
|
}
|
|
818
|
+
// Strip Tailwind preflight rules that conflict with Manifest's element-level
|
|
819
|
+
// resets. Tailwind's `hr { height: 0; border-top-width: 1px }` would win on
|
|
820
|
+
// specificity over Manifest's `:where(hr) {...}` reset (same `@layer base`,
|
|
821
|
+
// higher specificity), even when Manifest CSS loads after Tailwind. Removing
|
|
822
|
+
// the specific conflicting rules here is surgical: Tailwind's other utility
|
|
823
|
+
// classes (mt-6, md:hidden, etc.) keep their normal `@layer utilities`
|
|
824
|
+
// behaviour and continue to override Manifest's `*` reset as expected.
|
|
825
|
+
try {
|
|
826
|
+
const compiled = readFileSync(outCss, 'utf8');
|
|
827
|
+
// Inside Tailwind's `@layer base { ... }` block, remove the bare `hr { ... }`
|
|
828
|
+
// declaration only. Other element resets in the same layer don't conflict
|
|
829
|
+
// with Manifest's `:where()` resets (they target other elements or rely on
|
|
830
|
+
// Manifest's resets winning later in source order at equal specificity).
|
|
831
|
+
const stripped = compiled.replace(
|
|
832
|
+
/(\s*)hr\s*\{\s*height:\s*0;\s*color:\s*inherit;\s*border-top-width:\s*1px;?\s*\}/g,
|
|
833
|
+
''
|
|
834
|
+
);
|
|
835
|
+
if (stripped !== compiled) {
|
|
836
|
+
writeFileSync(outCss, stripped, 'utf8');
|
|
837
|
+
}
|
|
838
|
+
} catch (e) {
|
|
839
|
+
console.warn('prerender: failed to strip conflicting Tailwind preflight rules:', e?.message || e);
|
|
840
|
+
}
|
|
817
841
|
process.stdout.write(`prerender: wrote ${relative(rootDir, outCss)}\n`);
|
|
818
842
|
return true;
|
|
819
843
|
}
|