feat: split and hash static css
This commit is contained in:
@@ -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> {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user