🔥 Suppression du hack sur la config vitejs

Faux point d'entrée qui menait vers un fichier vide
pull/2113/head
Maxime Quandalle 2022-04-24 19:28:32 +02:00 committed by Maxime Quandalle
parent 5d562ab69b
commit c2014f73f6
4 changed files with 8 additions and 12 deletions

View File

@ -9,7 +9,6 @@
"directory": "site"
},
"private": true,
"main": "./source/entry-empty.js",
"engines": {
"node": ">=12.16.1"
},

View File

@ -3,6 +3,7 @@
// CommonJS when I wrote it.
// cf. https://github.com/vitejs/vite/blob/133fcea5223263b0ae08ac9a0422b55183ebd266/packages/vite/src/node/build.ts#L495
// cf. https://github.com/vitejs/vite/pull/2157
// cf. https://github.com/vitejs/vite/pull/6812
// TODO: We could use something like https://github.com/Aslemammad/tinypool to
// prerender all pages in parallel (used by vitest). Or move to SSR with a

View File

@ -1,3 +0,0 @@
// TODO: for some reason (ViteJS bug or missconfiguration on our side?) we need
// to define a entry file in the "main" field of package.json. We should remove
// this empty file when this problem is fixed.

View File

@ -157,20 +157,19 @@ function multipleSPA(options: MultipleSPAOptions): Plugin {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
vite.middlewares.use(async (req, res, next) => {
const url = req.originalUrl
const firstLevelDir = url?.slice(1).split('/')[0]
if (url === '/') {
res.writeHead(302, { Location: '/' + options.defaultSite })
res.end()
} else if (
url &&
Object.keys(options.sites).some((name) =>
url.slice(1).startsWith(name)
)
firstLevelDir &&
Object.keys(options.sites).some((name) => firstLevelDir === name)
) {
const siteName = url.slice(1).split('/')[0]
const siteName = firstLevelDir
const content = await vite.transformIndexHtml(
'/',
await fillTemplate(siteName),
url
url,
await fillTemplate(siteName)
)
res.end(content)
} else {