-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3265 from alibaba/release-next
- Loading branch information
Showing
72 changed files
with
834 additions
and
80 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: 使用 antd 组件 | ||
order: 12 | ||
order: 13 | ||
--- | ||
|
||
项目开发中如果使用 antd 组件作为基础 UI 组件,可以通过工程插件提供 antd 组件的按需加载和主题定制能力。 | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: CSS 网络资源本地化 | ||
order: 10 | ||
order: 11 | ||
--- | ||
|
||
组件代码里有可能会依赖一些远程 CDN 的字体文件等,某些网络可能访问不了,出现这个问题有几种情况: | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: 权限管理 | ||
order: 7 | ||
order: 8 | ||
--- | ||
|
||
对于一个 Web 应用,权限管理是经常会涉及的需求之一,通常包含以下几种常见的权限管理类型: | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: 后端应用集成 | ||
order: 15 | ||
order: 16 | ||
--- | ||
|
||
> 如果是阿里内部同学,请参考 [文档](https://yuque.alibaba-inc.com/ice/rdy99p/rpivf3) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
--- | ||
title: 构建时预渲染 Prerender | ||
order: 5 | ||
--- | ||
|
||
在某些业务场景下,需要更好的 SEO,提高首页加载速度等等,基于此 icejs 提供了构建时预渲染(Prerender)方案。 | ||
|
||
## 安装插件 | ||
|
||
```bash | ||
$ npm install build-plugin-prerender --save-dev | ||
``` | ||
|
||
## 工程配置 | ||
|
||
### 在 SPA 中 | ||
|
||
项目目录结构 | ||
|
||
```markdown | ||
├── src | ||
| ├── app.ts | ||
| ├── pages | ||
| | ├── About # About 页面 | ||
| | ├── Dashboard # Dashboard 页面 | ||
| | └── Home # Home 页面 | ||
| └── routes.ts | ||
``` | ||
|
||
在 build.json 中引入 `build-plugin-prerender` 并配置, 其中 `routes` 为需要渲染的路由。 | ||
|
||
```json | ||
{ | ||
"plugins": [ | ||
[ | ||
"build-plugin-prerender", | ||
{ | ||
"routes": [ | ||
"/", | ||
"/about", | ||
"/dashboard" | ||
] | ||
} | ||
] | ||
] | ||
} | ||
``` | ||
|
||
运行 `npm run build`,得到的构建产物如下: | ||
|
||
```markdown | ||
├── build | ||
| ├── about | ||
| | └── index.html # 预渲染得到的 HTML | ||
| ├── dashboard | ||
| | └── index.html # 预渲染得到的 HTML | ||
| ├── favicon.png | ||
| ├── index.html | ||
| └── js | ||
| └── index.js | ||
``` | ||
|
||
通过静态服务启动,通过预渲染后的 HTML 截图如下: | ||
|
||
![prerender-html](https://img.alicdn.com/tfs/TB1kihJJYj1gK0jSZFOXXc7GpXa-1364-738.png) | ||
|
||
### 在 MPA 中 | ||
|
||
项目目录结构 | ||
|
||
```markdown | ||
├── public | ||
| ├── dashboard.html | ||
| └── index.html | ||
├── src | ||
| └── pages | ||
| ├── Dashboard # Dashboard 页面 | ||
| └── Home # Home 页面 | ||
``` | ||
|
||
首先确保在 `build.json` 中开启 MPA 应用配置,`build-plugin-prerender` 配置字段同上 | ||
|
||
```json | ||
{ | ||
"mpa": true, | ||
"plugins": [ | ||
[ | ||
"build-plugin-prerender", | ||
{ | ||
"routes": [ | ||
"/about", | ||
"/dashboard" | ||
] | ||
} | ||
] | ||
] | ||
} | ||
``` | ||
|
||
运行 `npm run build`,得到的构建产物如下: | ||
|
||
```markdown | ||
├── build | ||
| ├── dashboard | ||
| | └── index.html | ||
| ├── home | ||
| | └── index.html | ||
| └── js | ||
| ├── dashboard.js | ||
| ├── home.js | ||
| └── vendor.js | ||
``` | ||
|
||
## 插件参数 | ||
|
||
- routes: `string[]`,需要预渲染的路由。默认是 `['/']`。 | ||
|
||
## 部署到 Nginx | ||
|
||
前端项目部署到 Nginx 时,可以在 Nginx 配置下加入以下内容,使得访问预渲染的路由时,可以获取到经过预渲染后的 HTML。 | ||
|
||
```nginx | ||
location / { | ||
root www/web; | ||
index index.html index.htm; | ||
+ try_files $uri $uri/ /index.html; | ||
} | ||
``` | ||
|
||
该功能为实验性功能,如遇到问题可通过飞冰钉钉群与我们反馈。 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: 前端资源发布 | ||
order: 13 | ||
order: 14 | ||
--- | ||
|
||
> 如果是阿里内部同学,请参考 [文档](https://yuque.antfin-inc.com/ice/rdy99p/syvuzh) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: 页面埋点统计数据 | ||
order: 16 | ||
order: 17 | ||
--- | ||
|
||
> 阿里内部用户请参考:https://yuque.antfin-inc.com/ice/rdy99p/paswzc | ||
|
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
Empty file.
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,21 @@ | ||
{ | ||
"mpa": true, | ||
"plugins": [ | ||
[ | ||
"build-plugin-prerender", | ||
{ | ||
"routes": [ | ||
"/home", | ||
"/dashboard" | ||
], | ||
"minify": { | ||
"collapseBooleanAttributes": false, | ||
"collapseWhitespace": false | ||
}, | ||
"renderer": { | ||
"maxConcurrentRoutes": 4 | ||
} | ||
} | ||
] | ||
] | ||
} |
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,21 @@ | ||
{ | ||
"name": "exmaple-with-prerender-mpa", | ||
"description": "", | ||
"dependencies": { | ||
"ice.js": "^1.0.11", | ||
"react": "^16.4.1", | ||
"react-dom": "^16.4.1", | ||
"build-plugin-prerender": "^1.5.1" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^16.9.13", | ||
"@types/react-dom": "^16.9.4" | ||
}, | ||
"scripts": { | ||
"start": "icejs start", | ||
"build": "icejs build" | ||
}, | ||
"engines": { | ||
"node": ">=8.0.0" | ||
} | ||
} |
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,16 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>icejs · prerender mpa example</title> | ||
</head> | ||
|
||
<body> | ||
<div>dashboard content of html template</div> | ||
<div id="ice-container"></div> | ||
</body> | ||
|
||
</html> |
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,15 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>icejs · prerender mpa example</title> | ||
</head> | ||
|
||
<body> | ||
<div id="ice-container"></div> | ||
</body> | ||
|
||
</html> |
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 @@ | ||
{ | ||
"template": "node", | ||
"container": { | ||
"port": 3333 | ||
} | ||
} |
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,10 @@ | ||
import { createApp, IAppConfig } from 'ice'; | ||
import routes from './routes'; | ||
|
||
const appConfig: IAppConfig = { | ||
router: { | ||
routes | ||
}, | ||
}; | ||
|
||
createApp(appConfig); |
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,18 @@ | ||
import * as React from 'react'; | ||
import { store } from 'ice/Dashboard'; | ||
|
||
const Dashboard = () => { | ||
const [pageState, pageActions] = store.useModel('counter'); | ||
return ( | ||
<> | ||
<h2>Dashboard Page...</h2> | ||
<div> | ||
<button type="button" onClick={pageActions.increment}>+</button> | ||
<span>{pageState.count}</span> | ||
<button type="button" onClick={pageActions.decrement}>-</button> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default Dashboard; |
Oops, something went wrong.