feat: split and hash static css

This commit is contained in:
saberzero1
2026-05-22 22:42:06 +02:00
parent 2e34c64c63
commit cfba672f51
6 changed files with 137 additions and 38 deletions
+11
View File
@@ -21,6 +21,13 @@ export type BuildTimeTrieData = QuartzPluginData & {
filePath: string
}
/**
* Mapping from logical asset names (e.g. "index.css") to their content-hashed
* filenames (e.g. "index-a3f2c1b.css"). Populated by the ComponentResources
* emitter before pages are rendered.
*/
export type HashedResourceNames = Record<string, string>
export interface BuildCtx {
buildId: string
argv: Argv
@@ -31,6 +38,10 @@ export interface BuildCtx {
incremental: boolean
/** Virtual pages generated by page type plugins (e.g. tag pages, folder pages, bases pages) */
virtualPages: ProcessedContent[]
/** Content-hashed asset filenames, populated by ComponentResources emitter */
hashedResourceNames?: HashedResourceNames
/** Maps CSS content strings to their emitted hashed filenames. Populated by ComponentResources. */
componentCssMap?: Map<string, string>
}
export function trieFromAllFiles(allFiles: QuartzPluginData[]): FileTrieNode<BuildTimeTrieData> {
+7
View File
@@ -68,6 +68,13 @@ export interface StaticResources {
}
export type StringResource = string | string[] | undefined
export function normalizeResource(resource: StringResource): string[] {
if (!resource) return []
if (Array.isArray(resource)) return resource
return [resource]
}
export function concatenateResources(...resources: StringResource[]): StringResource {
return resources
.filter((resource): resource is string | string[] => resource !== undefined)