https://sap.github.io/spartacus-docs/server-side-rendering-in-spartacus/
In Spartacus, server-side rendering allows you to render static versions of pages on the server side. This speeds up response times, assists with SEO, and allows the application to render more quickly. After Angular has bootstrapped, users of your site will have the full experience.
服务器端渲染页面的静态版本。服务器端渲染(Server Side Rendering,SSR)加快了应用的响应速度,有助于页面SEO-搜索引擎优化。
如何启用Spartacus SSR
The recommended way to add SSR support to your Spartacus application is to use schematics. With a single command, all required files are added automatically, and all modifications for SSR support are done automatically as well. To add SSR support to your Spartacus application, run the following command:
ng add @spartacus/schematics --ssr
1
Installation Steps for Spartacus Development
设置environment.prod.ts里的occBaseUrl:
关掉PWA:
As soon as Spartacus is installed in PWA mode, a service worker is installed, and it serves a cached version of index.html, along with the js files. This results in SSR being completely skipped. The following steps describe how to turn off PWA.
app.module.ts里,关闭pwa:
Compiling TypeScript sources through ngc
Bundling to FESM2015
Spartacus/core built完毕
Angular package built完毕
built输出位于projects/core和dist/core文件夹下面:
然后:Build your local Spartacus shell app by running the following command:
yarn build --prod
1
实际上执行的命令是:
ng build storefrontapp --prod --prod