Skip to content

Commit

Permalink
feat: pipeable strean
Browse files Browse the repository at this point in the history
- added mainfest
  • Loading branch information
denchiklut committed Jan 22, 2024
1 parent f37ab8b commit 3c2f692
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/client/components/@shared/html/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import type { FC, ReactNode } from 'react'
import { basePath } from 'src/common'

interface Props {
nonce: string
children: ReactNode
}
export const Html: FC<Props> = ({ children }) => {
export const Html: FC<Props> = ({ nonce, children }) => {
if (IS_SPA) return <>{children}</>

return (
<html>
<head>
<meta charSet='utf-8' />
<meta name='viewport' content='width=device-width, initial-scale=1' />
{IS_PROD && <link nonce={nonce} rel='manifest' href={basePath('manifest.json')} />}
<title>SSR app</title>
</head>

Expand Down
2 changes: 1 addition & 1 deletion src/client/components/home/posts/posts.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ function fetchPosts(): Promise<Array<{ id: number; text: string }>> {
text: 'You got that sand all over your feet'
}
])
}, 1100)
}, 3000)
})
}
7 changes: 1 addition & 6 deletions src/server/middleware/render/render.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { FC } from 'react'
import type { ServerResponse } from 'webpack-dev-middleware'
import type { ChunkExtractorOptions } from 'server/utils'
import requireFromString from 'require-from-string'
import { basePath, publicPath, AppProps } from 'src/common'
import { publicPath, AppProps } from 'src/common'

export const getStats = (res: ServerResponse): ChunkExtractorOptions => {
if (IS_PROD)
Expand All @@ -19,11 +19,6 @@ export const getStats = (res: ServerResponse): ChunkExtractorOptions => {
return { stats, publicPath: publicPath('/') }
}

export const getManifest = (nonce?: string) => {
if (IS_DEV) return ''
return `<link nonce='${nonce}' rel='manifest' href='${basePath('manifest.json')}' />`
}

export const getApp = (res: ServerResponse): { App: FC<AppProps> } => {
if (IS_PROD) return require('../client/js/app.server.js')

Expand Down
1 change: 1 addition & 0 deletions src/server/utils/chunk-extractor/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export function getFileScriptType(fileName: string) {

return script_types[extension] ?? null
}

export function isValidChunkAsset(chunkAsset: ChunkAsset) {
return chunkAsset.scriptType && !/\.hot-update\.js$/.test(chunkAsset.filename)
}
Expand Down

0 comments on commit 3c2f692

Please sign in to comment.