Skip to content

Commit

Permalink
fix: critter preload is not used
Browse files Browse the repository at this point in the history
  • Loading branch information
Daydreamer-riri committed Apr 10, 2024
1 parent e399bc3 commit 86149dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { serializeState } from '../utils/state'
import { buildLog, createRequest, getSize, removeLeadingSlash, resolveAlias, routesToPaths, withTrailingSlash } from './utils'
import { getCritters } from './critial'
import { render } from './server'
import { renderPreloadLinks } from './preload-links'
import { detectEntry, renderHTML } from './html'
import { renderPreloadLinks } from './preload-links'

export type SSRManifest = Record<string, string[]>
export interface ManifestItem {
Expand Down Expand Up @@ -188,8 +188,10 @@ export async function build(ssgOptions: Partial<ViteReactSSGOptions> = {}, viteC

const html = jsdom.serialize()
let transformed = (await onPageRendered?.(path, html, appCtx)) || html
if (critters)
if (critters) {
transformed = (await crittersQueue.add(() => critters.process(transformed)))!
transformed = transformed.replace(/<link\srel="stylesheet"/g, '<link rel="stylesheet" crossorigin')
}

if (styleTag)
transformed = transformed.replace('<head>', `<head>${styleTag}`)
Expand Down
1 change: 1 addition & 0 deletions src/node/preload-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function renderPreloadLink(document: Document, file: string) {
appendLink(document, {
rel: 'stylesheet',
href: file,
crossOrigin: '',
})
}
}
Expand Down

0 comments on commit 86149dc

Please sign in to comment.