question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CCv2 build and deploy with Spartacus 2.0

See original GitHub issue

Customers who try to run Spartacus 2 based Applications to ccv2 face build and deploy issues. Investigations are in progress, but we’re getting already some clues about the issue.

The fundamental issue is related to a changing file layout from angular 8 to 9. Spartacus 2 moved to Angular 9, and with this, customers would likely receive the standard angular 9 based file layout after building.

The angular 8 based file layout contains a dist folder with all the application build files in a subfolder. The SSR entry file (server.js) has been stored in the dist folder. (note: the main.js in the test-app-server is an intermediate build file and not used in ccv2 build/deploy).

image

The difference in the angular 9 based applications is that the client rendering and server rendering are separated in two named folders.

image

A couple of important changes:

  • The server.ts file has moved to the nested server folder
  • The index.html has moved to the nested browser folder

The different file layout is quite likely the root cause.

To be verified

  • It seems that the ccv2 build/deploy is copying the index.html to a location. Given that the underlying file structured changed, we seem to have a misalignment.
  • ~We don’t know if~ this is also causing issue for non-SSR deployments
  • The solution should be backwards compatible, ~moreover we’re not yet sure if recent changes affect the 1.5 releases~.
  • ~a quick code analysis of the ccv2 build process shows that the occ placeholder meta tag does not get replaced correctly~.

Potential Solution Directions

  • change the angular build process to adapt the current expected file layout (this could be quick win for current customers)
  • ~introduce a schematics to fit the ccv2 general file layout~
  • improve ccv2 to adapt both ng8 and ng9 file layout
  • add properties to the manifest.json so that customers are more in control
  • ~consider using package.json as an configurable script to start the application~

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:26 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
dunqancommented, Jul 15, 2020

Hi! what if additionally, we copy the app-name/dist/server/main.js file to app-name/dist/server.js, and change the serve:ssr task in the package.json file to execute node app-name/dist/server.js, would that make it work (while the ccv2 fix is implemented)?

Yes @arelsirin , it should work and it’s now a recommended workaround as fixing it in CCV2 might be delayed because of various reasons.

One way to make it automated, is for example to adding && mv dist/app-folder-server/main.js dist/server.js || move dist\\app-folder-server\\main.js dist\\server.js", to build:ssr command in package.json.

2reactions
dunqancommented, Jun 17, 2020

As initially discussed with ccv2 team members, we would like to make manifest.json more configurable, to accommodate more specific cases (and keep backward compatibility with current solutions). Also, for now, the best approach is to adapt Angular build process to match the expected layout, which means:

  • change of outputPaths in angular.json
    • "outputPath": "dist/app-name/browser", to "outputPath": "dist/app-name",
    • "outputPath": "dist/app-name/server", tp "outputPath": "dist/app-name-server",
  • change in server,ts:
    • const distFolder = join(process.cwd(), 'dist/app-name/browser'); to const distFolder = join(process.cwd(), 'dist/app-name');
Read more comments on GitHub >

github_iconTop Results From Across the Web

Workaround for Issue with Server-Side Rendering in ... - SAP
This document describes a temporary workaround for a problem with running Spartacus 2.0 with Server-Side Rendering (SSR) on SAP Commerce Cloud in the...
Read more >
Deploy spartacus on Cloud - SAP Community
hi , I need deploy spartacus on cloud, but I do not find guide. I have three environment; dev, stage, prod, but I...
Read more >
Build and Deployment in SAP Commerce Cloud V2
Commerce Cloud build API now allows for automated build and deplyments across your SAP Commerce Cloud V2 (CCV2). Explore our recent PoC blog....
Read more >
How to deploy Commerce and Spartacus to ccv2
Please guide how we can move both Spartacus and Commerce code bases and doing the performing build and deployment.
Read more >
A First-Mover's Guide to SAP Commerce Cloud V2 Migration
Scaling Automation: Using containerization — and a new set of cloud-based build tools — CCV2 offers improved automation features for application deployment ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found