feat: split and hash static css
This commit is contained in:
@@ -55,7 +55,14 @@ export async function emitContent(ctx: BuildCtx, content: ProcessedContent[]) {
|
||||
let emittedFiles = 0
|
||||
const staticResources = getStaticResourcesFromPlugins(ctx)
|
||||
|
||||
// Phase 1: Run PageTypeDispatcher first so it populates ctx.virtualPages
|
||||
// Phase 0: Run ComponentResources first so content-hashed asset filenames
|
||||
// (e.g. index-a3f2c1b.css) are available on ctx before pages are rendered.
|
||||
const componentResources = cfg.plugins.emitters.find((e) => e.name === "ComponentResources")
|
||||
if (componentResources) {
|
||||
emittedFiles += await runEmitter(componentResources, ctx, content, staticResources, log)
|
||||
}
|
||||
|
||||
// Phase 1: Run PageTypeDispatcher so it populates ctx.virtualPages
|
||||
// with pages generated by page type plugins (tag pages, folder pages, bases pages, etc.)
|
||||
const dispatcher = cfg.plugins.emitters.find((e) => e.name === "PageTypeDispatcher")
|
||||
if (dispatcher) {
|
||||
@@ -68,7 +75,9 @@ export async function emitContent(ctx: BuildCtx, content: ProcessedContent[]) {
|
||||
// (e.g. sitemap, RSS, contentIndex.json used by the explorer sidebar).
|
||||
const contentWithVirtual =
|
||||
ctx.virtualPages.length > 0 ? [...content, ...ctx.virtualPages] : content
|
||||
const otherEmitters = cfg.plugins.emitters.filter((e) => e.name !== "PageTypeDispatcher")
|
||||
const otherEmitters = cfg.plugins.emitters.filter(
|
||||
(e) => e.name !== "PageTypeDispatcher" && e.name !== "ComponentResources",
|
||||
)
|
||||
const counts = await Promise.all(
|
||||
otherEmitters.map((emitter) =>
|
||||
runEmitter(emitter, ctx, contentWithVirtual, staticResources, log),
|
||||
|
||||
Reference in New Issue
Block a user