This is a simple monorepo setup to test Stencil SSG (prerendering). The repo consists of two packages:
packages/stencil-library
: A Stencil component librarypackages/server-app
: A Node app that consumes the Stencil hydrate script to serve static HTML
- From project root, run
npx lerna bootstrap
to install dependencies for all packages - From project root, run
cd packages/stencil-library && npm run build
to create the hydrate script - From project root, run
cd packages/server-app && npm start
to spin-up the Node server on port8888
The Node app uses the renderToString()
method from the Stencil Hydrate App to
easily convert an HTML string to valid HTML. The transformed HTML is then written to the server response.
To change what is rendered, you can modify the call to renderToString()
in packages/server-app/srs/index.ts
with whatever HTML you want. All
web components defined in packages/stencil-library
are available to use in the HTML string. If you modify the Stencil library, you will
need to rebuild the library package (cd packages/stencil-library && npm run build
). The packages are symbolically linked via Lerna, so you
do not need to install an updated build of the Stencil library.