-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: router base not working for ssr and export static (#12140)
* fix: ssr exportStatic not handle with base * fix: update pnpm-lock.yaml * fix: 修复 getClientRootComponent 方法. 增加 ssr basename 案例 * fix: 解决 exportStatic 文件冲突 * fix: 修复合并冲突导致的问题 * fix: 完善例子 * fix: 完善例子
- Loading branch information
Showing
17 changed files
with
205 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
exportStatic: {}, | ||
ssr: {}, | ||
base: '/base/', | ||
publicPath: '/base/', // 布署时需要布署在 base 文件夹下. | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "@example/ssg-basename", | ||
"private": true, | ||
"description": "该案例用于测试 ssg 预渲染. 当 umi 配置表中设置了 base 后, ssg 输出的预渲染页面中的 a 标签需要有正确的 base 前缀", | ||
"scripts": { | ||
"build": "umi build", | ||
"dev": "umi dev", | ||
"setup": "umi setup", | ||
"start": "npm run dev" | ||
}, | ||
"dependencies": { | ||
"umi": "workspace:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
|
||
import { Outlet } from 'umi'; | ||
|
||
const Layout = () => { | ||
return ( | ||
<div> | ||
<div style={{ marginBottom: '10px' }}>HEADER</div> | ||
<Outlet /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { useState } from 'react'; | ||
import { Link } from 'umi'; | ||
|
||
const About = () => { | ||
const [num, setNum] = useState(0); | ||
|
||
return ( | ||
<div> | ||
<div> | ||
<strong>ABOUT</strong> page | ||
<button | ||
style={{ marginLeft: '5px' }} | ||
onClick={() => setNum((val) => val + 1)} | ||
> | ||
couts: {num} | ||
</button> | ||
</div> | ||
<br /> | ||
<Link to="/">to home</Link> | ||
</div> | ||
); | ||
}; | ||
|
||
export default About; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { useState } from 'react'; | ||
import { Link } from 'umi'; | ||
|
||
const Home = () => { | ||
const [num, setNum] = useState(0); | ||
return ( | ||
<div> | ||
<div> | ||
<strong>HOME</strong> page | ||
<button | ||
style={{ marginLeft: '5px' }} | ||
onClick={() => setNum((val) => val + 1)} | ||
> | ||
couts: {num} | ||
</button> | ||
</div> | ||
|
||
<br /> | ||
<Link to="/about">to about</Link> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Home; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default { | ||
ssr: {}, | ||
exportStatic: {}, | ||
base: '/base/', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "@example/ssr-basename", | ||
"private": true, | ||
"description": "该案例用于测试 SSR 中带 basename 的情况. 在 dev 或 build 下, 服务端需要返回正确的 html 片段, 比如 a 标签需要有正确的 base 前缀", | ||
"scripts": { | ||
"build": "umi build", | ||
"dev": "umi dev", | ||
"setup": "umi setup", | ||
"start": "npm run dev" | ||
}, | ||
"dependencies": { | ||
"umi": "workspace:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
|
||
import { Outlet } from 'umi'; | ||
|
||
const Layout = () => { | ||
return ( | ||
<div> | ||
<div style={{ marginBottom: '10px' }}>HEADER</div> | ||
<Outlet /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { useState } from 'react'; | ||
import { Link } from 'umi'; | ||
|
||
const About = () => { | ||
const [num, setNum] = useState(0); | ||
|
||
return ( | ||
<div> | ||
<div> | ||
<strong>ABOUT</strong> page | ||
<button | ||
style={{ marginLeft: '5px' }} | ||
onClick={() => setNum((val) => val + 1)} | ||
> | ||
couts: {num} | ||
</button> | ||
</div> | ||
<br /> | ||
<Link to="/">to home</Link> | ||
</div> | ||
); | ||
}; | ||
|
||
export default About; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { useState } from 'react'; | ||
import { Link } from 'umi'; | ||
|
||
const Home = () => { | ||
const [num, setNum] = useState(0); | ||
return ( | ||
<div> | ||
<div> | ||
<strong>HOME</strong> page | ||
<button | ||
style={{ marginLeft: '5px' }} | ||
onClick={() => setNum((val) => val + 1)} | ||
> | ||
couts: {num} | ||
</button> | ||
</div> | ||
|
||
<br /> | ||
<Link to="/about">to about</Link> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Home; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.