Angular ng 构建预渲染路由,如 angular 通用静态服务(带有开放图 og 标签)
Angular ng build prerendered routes like angular universal for static serving (with open graph og tags)
是否可以构建一个 angular 应用程序 (angular 2/3/4/5) 用于生产(使用 AoT)并使用多个预渲染路由?我正在考虑类似于 angular 通用的东西,只是在预定义路由的构建过程中。
例如:
./dist/index.html << this is default!
// Additional build prerendered index.html files for specified routes
./dist/routeA/index.html
./dist/routeB/index.html
./dist/routeC/customRouteParam/index.html
为什么要对 Angular 进行静态预渲染?
- 来自 s3 的静态服务
- 避免服务器端渲染的额外复杂性
- 保持通用应用程序和服务器端渲染的优势
- 缩短加载时间
- 支持 Open Graph 标签(OG 标签)
服务器端渲染 Angular 通用
我知道 angular 通用服务器端预渲染是可能的,但我想避免这种额外的复杂性,而是托管完全静态的。对于 angular 通用服务器端呈现感兴趣的任何人,以下资源可能会有用:
您可以使用 universal 进行预渲染,然后静态地提供 html 个文件
初学者工具包有一个示例文件,prerender.ts,展示了它是如何完成的。
https://github.com/angular/universal-starter.
您只需提供一个已知路由列表进行预渲染,然后执行服务器端渲染并将结果 html 保存到磁盘。
我将这种方法用于一个网站,该网站的内容每隔几个月才更改一次,而且速度非常快
是否可以构建一个 angular 应用程序 (angular 2/3/4/5) 用于生产(使用 AoT)并使用多个预渲染路由?我正在考虑类似于 angular 通用的东西,只是在预定义路由的构建过程中。
例如:
./dist/index.html << this is default!
// Additional build prerendered index.html files for specified routes
./dist/routeA/index.html
./dist/routeB/index.html
./dist/routeC/customRouteParam/index.html
为什么要对 Angular 进行静态预渲染?
- 来自 s3 的静态服务
- 避免服务器端渲染的额外复杂性
- 保持通用应用程序和服务器端渲染的优势
- 缩短加载时间
- 支持 Open Graph 标签(OG 标签)
服务器端渲染 Angular 通用
我知道 angular 通用服务器端预渲染是可能的,但我想避免这种额外的复杂性,而是托管完全静态的。对于 angular 通用服务器端呈现感兴趣的任何人,以下资源可能会有用:
您可以使用 universal 进行预渲染,然后静态地提供 html 个文件
初学者工具包有一个示例文件,prerender.ts,展示了它是如何完成的。 https://github.com/angular/universal-starter.
您只需提供一个已知路由列表进行预渲染,然后执行服务器端渲染并将结果 html 保存到磁盘。
我将这种方法用于一个网站,该网站的内容每隔几个月才更改一次,而且速度非常快