Skip to content

Commit

Permalink
Revert "feat: add ssr.prerender configuration for umi build prerender (
Browse files Browse the repository at this point in the history
…umijs#7269)" (umijs#7282)

This reverts commit d1ac759.
  • Loading branch information
sorrycc authored Sep 8, 2021
1 parent d1ac759 commit c15f5b6
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 90 deletions.
2 changes: 0 additions & 2 deletions docs/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,6 @@ __webpack_public_path__ = window.resourceBaseUrl || window.publicPath;
// devServerRender: true,
// mode: 'string',
// staticMarkup: false,
// prerender: true
}
}
```
Expand All @@ -1130,7 +1129,6 @@ __webpack_public_path__ = window.resourceBaseUrl || window.publicPath;
- `devServerRender`:在 `umi dev` 开发模式下,执行渲染,用于 umi SSR 项目的快速开发、调试,服务端渲染效果所见即所得,同时我们考虑到可能会与服务端框架(如 [Egg.js](https://eggjs.org/)[Express](https://expressjs.com/)[Koa](https://koajs.com/))结合做本地开发、调试,关闭后,在 `umi dev` 下不执行服务端渲染,但会生成 `umi.server.js`(Umi SSR 服务端渲染入口文件),渲染开发流程交由开发者处理。
- `mode`:渲染模式,默认使用 `string` 字符串渲染,同时支持流式渲染 `mode: 'stream'`,减少 TTFB(浏览器开始收到服务器响应数据的时间) 时长。
- `staticMarkup`:html 上的渲染属性(例如 React 渲染的 `data-reactroot`),常用于静态站点生成的场景上。
- `prerender`: SSR umi build 时是否开启 SSR HTML 预渲染,默认为 true。

注意:

Expand Down
2 changes: 0 additions & 2 deletions docs/config/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,6 @@ __webpack_public_path__ = window.resourceBaseUrl || window.publicPath;
// devServerRender: true,
// mode: 'string',
// staticMarkup: false,
// prerender: true
}
}
```
Expand All @@ -1129,7 +1128,6 @@ __webpack_public_path__ = window.resourceBaseUrl || window.publicPath;
- `devServerRender`:在 `umi dev` 开发模式下,执行渲染,用于 umi SSR 项目的快速开发、调试,服务端渲染效果所见即所得,同时我们考虑到可能会与服务端框架(如 [Egg.js](https://eggjs.org/)[Express](https://expressjs.com/)[Koa](https://koajs.com/))结合做本地开发、调试,关闭后,在 `umi dev` 下不执行服务端渲染,但会生成 `umi.server.js`(Umi SSR 服务端渲染入口文件),渲染开发流程交由开发者处理。
- `mode`:渲染模式,默认使用 `string` 字符串渲染,同时支持流式渲染 `mode: 'stream'`,减少 TTFB(浏览器开始收到服务器响应数据的时间) 时长。
- `staticMarkup`:html 上的渲染属性(例如 React 渲染的 `data-reactroot`),常用于静态站点生成的场景上。
- `prerender`: umi build 时是否开启 SSR HTML 预渲染,默认为 true。

注意:

Expand Down
10 changes: 0 additions & 10 deletions packages/preset-built-in/src/fixtures/ssr-prerender-no/.umirc.ts

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions packages/preset-built-in/src/fixtures/ssr-prerender/.umirc.ts

This file was deleted.

This file was deleted.

34 changes: 0 additions & 34 deletions packages/preset-built-in/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,37 +433,3 @@ test('exportStatic', async () => {
expect(existsSync(join(cwd, 'dist', 'list', ':id.html'))).toBeTruthy();
}
});

test('ssr prerender', async () => {
const cwd = join(fixtures, 'ssr-prerender');
const service = new Service({
cwd,
env: 'production',
presets: [require.resolve('../lib/index.js')],
});
await service.run({
name: 'build',
args: {},
});
expect(existsSync(join(cwd, 'dist', 'index.html'))).toBeTruthy();
const html = readFileSync(join(cwd, 'dist', 'index.html'), 'utf8');
expect(
html.includes('<div id="root"><div><h2>prerender</h2></div></div>'),
).toBeTruthy();
});

test('ssr prerender false', async () => {
const cwd = join(fixtures, 'ssr-prerender-no');
const service = new Service({
cwd,
env: 'production',
presets: [require.resolve('../lib/index.js')],
});
await service.run({
name: 'build',
args: {},
});
expect(existsSync(join(cwd, 'dist', 'index.html'))).toBeTruthy();
const html = readFileSync(join(cwd, 'dist', 'index.html'), 'utf8');
expect(html.includes('<div id="root"></div>')).toBeTruthy();
});
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ export default (api: IApi) => {
);
const { ssr } = api.config;
if (
ssr &&
ssr.prerender !== false &&
ssr &&
api.env === 'production' &&
existsSync(serverFilePath) &&
!isDynamicRoute(route.path!)
Expand Down
5 changes: 0 additions & 5 deletions packages/preset-built-in/src/plugins/features/ssr/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ export default (api: IApi) => {
staticMarkup: joi
.boolean()
.description('static markup in static site'),
prerender: joi
.boolean()
.description(
'whether to enable pre-rendering when umi build export static mode',
),
})
.without('forceInitial', ['removeWindowInitialProps'])
.error(
Expand Down
1 change: 0 additions & 1 deletion packages/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ export interface ISSR {
devServerRender?: boolean;
mode?: 'string' | 'stream';
staticMarkup?: boolean;
prerender?: boolean;
}

export interface ICopy {
Expand Down

0 comments on commit c15f5b6

Please sign in to comment.