| | import type { CssResource } from '../../build/webpack/plugins/flight-manifest-plugin' |
| | import { encodeURIPath } from '../../shared/lib/encode-uri-path' |
| | import type { AppRenderContext } from './app-render' |
| | import { getAssetQueryString } from './get-asset-query-string' |
| | import type { PreloadCallbacks } from './types' |
| |
|
| | |
| | |
| | |
| | |
| | |
| | export function renderCssResource( |
| | entryCssFiles: CssResource[], |
| | ctx: AppRenderContext, |
| | preloadCallbacks?: PreloadCallbacks |
| | ) { |
| | const { |
| | componentMod: { createElement }, |
| | } = ctx |
| | return entryCssFiles.map((entryCssFile, index) => { |
| | |
| | |
| | |
| | |
| | |
| | |
| | const precedence = |
| | process.env.NODE_ENV === 'development' |
| | ? 'next_' + entryCssFile.path |
| | : 'next' |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | const fullHref = `${ctx.assetPrefix}/_next/${encodeURIPath( |
| | entryCssFile.path |
| | )}${getAssetQueryString(ctx, true)}` |
| |
|
| | if (entryCssFile.inlined && !ctx.parsedRequestHeaders.isRSCRequest) { |
| | return createElement( |
| | 'style', |
| | { |
| | key: index, |
| | nonce: ctx.nonce, |
| | precedence: precedence, |
| | href: fullHref, |
| | }, |
| | entryCssFile.content |
| | ) |
| | } |
| |
|
| | preloadCallbacks?.push(() => { |
| | ctx.componentMod.preloadStyle( |
| | fullHref, |
| | ctx.renderOpts.crossOrigin, |
| | ctx.nonce |
| | ) |
| | }) |
| |
|
| | return createElement('link', { |
| | key: index, |
| | rel: 'stylesheet', |
| | href: fullHref, |
| | precedence: precedence, |
| | crossOrigin: ctx.renderOpts.crossOrigin, |
| | nonce: ctx.nonce, |
| | }) |
| | }) |
| | } |
| |
|