Ajouter SSR prerending, espace employe, formulaire inscription employee depuis admin

This commit is contained in:
Alexis SANOGO
2026-09-04 16:08:22 +02:00
parent dfa5fb81a3
commit 28d743deb5
12 changed files with 279 additions and 177 deletions

View File

@@ -0,0 +1,54 @@
import { mkdirSync, writeFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { preview } from 'vite'
import { chromium } from 'playwright'
const __dirname = dirname(fileURLToPath(import.meta.url))
const root = join(__dirname, '..')
const distDir = join(root, 'dist')
// Pages publiques, indexables (voir public/robots.txt) : ce sont les seules
// qui ont besoin d'un HTML pré-rendu pour le SEO et les aperçus sociaux. Les
// pages privées (profil, mes gains, admin...) restent en rendu 100% client,
// servies par le index.html générique via le fallback SPA de nginx.
const ROUTES = [
'/accueil',
'/notre-concept',
'/regles-jeu',
'/contact',
'/mentions-legales',
'/confidentialite',
'/accessibilite',
'/cgu',
'/sitemap',
'/inscription',
'/connexion',
]
async function main() {
const server = await preview({ root, preview: { port: 4173, strictPort: false } })
const base = server.resolvedUrls.local[0].replace(/\/$/, '')
const browser = await chromium.launch()
const page = await browser.newPage()
for (const route of ROUTES) {
await page.goto(`${base}${route}`, { waitUntil: 'networkidle' })
await page.waitForSelector('h1')
const html = await page.content()
const outDir = join(distDir, route.replace(/^\//, ''))
mkdirSync(outDir, { recursive: true })
writeFileSync(join(outDir, 'index.html'), `<!doctype html>\n${html}`)
console.log(`✓ pré-rendu ${route} -> dist${route}/index.html`)
}
await browser.close()
await server.close()
}
main().catch((error) => {
console.error('Erreur de pré-rendu :', error)
process.exit(1)
})