Chersite front app is a React SPA/SSG/SSR framework, built with vite, react,typescript, sass and @cher-ami/router on the top.
When chersite is built, it automatically creates three types of apps. It allows you to choose to use the one that best suits the type of project.
The SSR app provides a server.prod.js
, to run on production. The client code will hydrate the server response on the fly.
Output:
dist/
- ssr/
- client/ ← SSR client code
- scripts/ ← contains the server.prod.js for stating the SSR app with "npm run start"
npm run build:ssr && npm run start
chersite front allows to generate a static HTML files with prerender
.
the main thinks to consider is, the prerender
fonction needs to know the list of routes to generate as static html files.
You have to list manually all routes you want to prerender in prerender/urls.ts:
return new Promise((resolve) => {
resolve([
"/", // → /index.html
"/work", // → /work/index.html
"/work/first" // → /work/first.html
])
})
By default, the generate command is executed on build step, but you can run it manually:
npm build:static
Output:
dist/
- static/
- client/ ← static page generated client code
- scripts/ ← contains prerender.js and exe-server-prerender.js used to execute generate task
The single page application can be useful in some case (embedded sites for example) but not the best choice for SEO.
npm run build:spa
Output:
dist/
- spa/ ← single page application
There is two entry points on the app. Both can be edited, depends of usage
- server side src/index-server.tsx: Contains the root tree of the application.
- client side src/index-client.tsx: Contains the client root app witch hydrate the server-side DOM rendering, or create a new root for SPA.
Vite's configuration is managed by:
- vite.config.ts: contains the whole vite config (vite config documentation)
- vite.ssr-scripts.config.ts: contains the whole vite scripts config. It built scripts files relative to the SSR.
- vite.static-scripts.config.ts: contains the whole vite scripts config. It built scripts files relative to the static generator.
- config/config.js: contains the internal paths.
npm scripts command line interface is available from the main package.json
npm run ...
:
dev
- start dev-serverbuild:spa
- build spa website typebuild:ssr
- build SSR website typebuild:static
- build static website typebuild
- build all website's typesstart
- run the SSR prod server
-
Generate a self-signed certificate from
apps/front
root folder:sudo openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
-
Trust the certificate:
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain cert.pem
-
Update .env var
PROTOCOL
tohttps
PROTOCOL=https
When you run npm run dev
, you should see the app running on https://localhost:5173
Developed by cher-ami team.