This repository was archived by the owner on May 8, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +13
-9
lines changed
Expand file tree Collapse file tree 8 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ const dev = () => {
7777
7878``` js
7979const commonNode = props => (
80- // 为了同时兼容ssr/csr请保留此判断,如果你的layout没有内容请使用 props.children ? { props.children } : ''
80+ // 为了同时兼容ssr/csr请保留此判断,如果你的layout没有内容请使用 props.children ? <div> { props.children }</div> : ''
8181 // 作为承载csr应用页面模版时,我们只需要返回一个空的节点
8282 props .children ? < div className= ' normal' >< h1 className= ' title' >< Link to= ' /' > Egg + React + SSR < / Link>< div className= ' author' > by ykfe< / div>< / h1> {props .children }< / div>
8383 : ' '
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ import { Link } from 'react-router-dom'
6868import serialize from ' serialize-javascript'
6969
7070const commonNode = props => (
71- // 为了同时兼容ssr/csr请保留此判断,如果你的layout没有内容请使用 props.children ? { props.children } : ''
71+ // 为了同时兼容ssr/csr请保留此判断,如果你的layout没有内容请使用 props.children ? <div> { props.children }</div> : ''
7272 props .children ? < div className= ' normal' >< h1 className= ' title' >< Link to= ' /' > Egg + React + SSR < / Link>< div className= ' author' > by ykfe< / div>< / h1> {props .children }< / div>
7373 : ' '
7474)
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { Link } from 'react-router-dom'
66import serialize from 'serialize-javascript'
77
88const commonNode = props => (
9- // 为了同时兼容ssr/csr请保留此判断,如果你的layout没有内容请使用 props.children ? { props.children } : ''
9+ // 为了同时兼容ssr/csr请保留此判断,如果你的layout没有内容请使用 props.children ? <div> { props.children }</div> : ''
1010 props . children ? < div className = 'normal' > < h1 className = 'title' > < Link to = '/' > Egg + React + SSR</ Link > < div className = 'author' > by ykfe</ div > </ h1 > { props . children } </ div >
1111 : ''
1212)
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { Link } from 'react-router-dom'
66import serialize from 'serialize-javascript'
77
88const commonNode = props => (
9- // 为了同时兼容ssr/csr请保留此判断,如果你的layout没有内容请使用 props.children ? { props.children } : ''
9+ // 为了同时兼容ssr/csr请保留此判断,如果你的layout没有内容请使用 props.children ? <div> { props.children }</div> : ''
1010 props . children ? < div className = 'normal' > < h1 className = 'title' > < Link to = '/' > Egg + React + SSR</ Link > < div className = 'author' > by ykfe</ div > </ h1 > { props . children } </ div >
1111 : ''
1212)
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import '@/assets/common.less'
66import './index.less'
77
88const commonNode = props => (
9- // 为了同时兼容ssr/csr请保留此判断,如果你的layout没有内容请使用 props.children ? { props.children } : ''
9+ // 为了同时兼容ssr/csr请保留此判断,如果你的layout没有内容请使用 props.children ? <div> { props.children }</div> : ''
1010 props . children
1111 ? < div className = 'normal' > < h1 className = 'title' > < Link to = '/' > Egg + React + SSR</ Link > < div className = 'author' > by ykfe</ div > </ h1 > { props . children } </ div >
1212 : ''
Original file line number Diff line number Diff line change 22const path = require ( 'path' )
33const webpack = require ( 'webpack' )
44const merge = require ( 'webpack-merge' )
5- const baseConfig = require ( './webpack.config.base' )
65const TerserPlugin = require ( 'terser-webpack-plugin' )
76const OptimizeCSSAssetsPlugin = require ( 'optimize-css-assets-webpack-plugin' )
8- const paths = require ( './paths' )
97const ManifestPlugin = require ( 'webpack-manifest-plugin' )
108const ModuleNotFoundPlugin = require ( 'react-dev-utils/ModuleNotFoundPlugin' )
119const safePostCssParser = require ( 'postcss-safe-parser' )
1210const BundleAnalyzerPlugin = require ( 'webpack-bundle-analyzer' ) . BundleAnalyzerPlugin
11+ const baseConfig = require ( './webpack.config.base' )
12+ const paths = require ( './paths' )
1313const publicPath = '/'
1414const shouldUseSourceMap = process . env . GENERATE_SOURCEMAP !== 'false'
1515const isDev = process . env . NODE_ENV === 'development'
Original file line number Diff line number Diff line change @@ -15,8 +15,9 @@ const Layout = (props) => {
1515 if ( __isBrowser__ ) {
1616 return commonNode ( props )
1717 } else {
18- const { serverData } = props . layoutData
18+ const { serverData, req } = props . layoutData
1919 const { injectCss, injectScript } = props . layoutData . app . config
20+ const chunkName = req ? req . url . split ( '/' ) [ 1 ] : ''
2021 return (
2122 < html lang = 'en' >
2223 < head >
@@ -27,6 +28,9 @@ const Layout = (props) => {
2728 {
2829 injectCss && injectCss . map ( item => < link rel = 'stylesheet' href = { item } key = { item } /> )
2930 }
31+ {
32+ ( chunkName && chunkName ) ? < link rel = 'stylesheet' href = { `/static/css/${ chunkName } .chunk.css` } /> : ''
33+ }
3034 </ head >
3135 < body >
3236 < div id = 'app' > { commonNode ( props ) } </ div >
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { Link } from 'react-router-dom'
66import serialize from 'serialize-javascript'
77
88const commonNode = props => (
9- // 为了同时兼容ssr/csr请保留此判断,如果你的layout没有内容请使用 props.children ? { props.children } : ''
9+ // 为了同时兼容ssr/csr请保留此判断,如果你的layout没有内容请使用 props.children ? <div> { props.children }</div> : ''
1010 props . children ? < div className = 'normal' > < h1 className = 'title' > < Link to = '/' > Egg + React + SSR</ Link > < div className = 'author' > by ykfe</ div > </ h1 > { props . children } </ div >
1111 : ''
1212)
You can’t perform that action at this time.
0 commit comments