Debug a Server–Side Rendered SAP Spartacus Storefront Using Chrome Dev Tools

简介: Debug a Server–Side Rendered SAP Spartacus Storefront Using Chrome Dev Tools

In SAP Spartacus document there is a page for “How to Debug a Server–Side Rendered Storefront” using Visual Studio Code.


https://sap.github.io/spartacus-docs/3.x/how-to-debug-server-side-rendered-storefront/


This document just introduces another way to debug, using Chrome Dev Tools instead of Visual Studio Code.The steps are written based on Spartacus library with version 3.4.1.


(1) create a Storefront using Spartacus library and enable it with SSR support using Schematics,by following this document:


https://sap.github.io/spartacus-docs/3.x/building-the-spartacus-storefront-from-libraries-3-4/


(2) By default a script build:ssr is generated to build Storefront and launch it in SSR mode.

image.png

The build option --prod and production configuration is used so it means in this way you have to debug a version with minified and uglified code.


So we can create another script build:ssrdev with --prod and production configuration removed, so it comes with this content:


ng build && ng run mystore:server


image.png


In this way, check the bundles generated in folder server,we have un-minified source code which is easier for debugging now.


image.png


(3) add --inspect-brk option in node command in package.json file:


cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 node --inspect-brk dist/mystore/server/main.js


image.png

npm run serve:ssr


image.png

(4) open chrome://inspect,press “inspect” hyperlink:


image.png


Then Chrome dev tools opens, with breakpoint stopped at the first line of main.js bundle, thanks to the --inspect-brk option:


image.png


Now we can debug at will. Press Ctrl + O and type the name of the file in which we would like to debug:


image.png


For example,if I would like to debug HTML tag generation process for SEO purpose, I can set breakpoint in file spartacus-storefront.js, class SeoMetaService.We can now just debug the Storefront running in SSR mode, just like the same when it is rendered using CSR ( Client Side Render ) mode.


Happy debugging!


image.png

相关文章
|
2月前
|
IDE JavaScript 开发工具
什么是 SAP Fiori tools 的 environment check 功能
什么是 SAP Fiori tools 的 environment check 功能
26 0
|
6月前
|
中间件
SAP UI5 Tools 的 Custom UI5 Server Middleware 介绍
SAP UI5 Tools 的 Custom UI5 Server Middleware 介绍
65 1
|
6月前
|
前端开发 JavaScript 中间件
SAP Fiori Tools 的 Application Reload Middleware 介绍
SAP Fiori Tools 的 Application Reload Middleware 介绍
50 0
upload Fiori application to ABAP server via report /UI5/UI5_REPOSITORY_LOAD
upload Fiori application to ABAP server via report /UI5/UI5_REPOSITORY_LOAD
110 0
upload Fiori application to ABAP server via report /UI5/UI5_REPOSITORY_LOAD
|
JSON 数据格式
Fiori Launchpad server side config json
Fiori Launchpad server side config json
Fiori Launchpad server side config json
|
IDE 开发工具
How to check accessibility errors via Web IDE
How to check accessibility errors via Web IDE
How to check accessibility errors via Web IDE
Hybris做增强的两种方式:In App Extension和Side by Side Extension
Hybris做增强的两种方式:In App Extension和Side by Side Extension
Hybris做增强的两种方式:In App Extension和Side by Side Extension
|
Web App开发
SAP Spartacus 的googleapis和firefox的NS_BINDING_ABORTED错误
如果在firefox里加载SAP Spartacus, 遇到NS_BINDING_ABORTED错误:
SAP Spartacus 的googleapis和firefox的NS_BINDING_ABORTED错误
|
SQL API
Fiori UI上创建的note和web client UI上note的对应关系
Fiori UI上创建的note和web client UI上note的对应关系
Fiori UI上创建的note和web client UI上note的对应关系