Angular SSR with wildfly

A search a solution Server side rendering with angular on wildfly. But I don't want to use other server, like nodejs.

Is any reliable solution? Or the best way the Angular universal?

Upvotes: 0

Views: 122

Answers (1)

Pieterjan
Pieterjan

Reputation: 3581

If you don't want to leverage on NodeJS, and your angular app only has static content, then you can use prerendering.

After adding @nguniversal to your project, you get a new command in your root package.json

"prerender": "ng run prerendering-demo:prerender"

Running this command will produce only html, css and javascript files. javascript navigation is still enabled. So after running

npm run prerender

You can simply upload the output in the dist/[project name]/browser folder to a simple webserver to host your app. I tested this with the following commands

ng new prerendering-demo --style=scss --routing --strict
cd prerendering-demo
ng add @nguniversal/express-engine

cd src/app
ng g module --routing pages
cd pages
ng g module home --module pages --route /
ng g module about --module pages --route about
ng g module contact --module pages --route contact
# just correct the / for the homepage in the pages-routing.module.ts

npm run prerender
npm install --global http-server
cd ../../dist/prerendering-demo/browser
http-server
# Visit http://127.0.0.1:8081

Upvotes: 1

Related Questions