Skip to content

Commit

Permalink
🔥 Suppression du hack sur la config vitejs
Browse files Browse the repository at this point in the history
Faux point d'entrée qui menait vers un fichier vide
  • Loading branch information
mquandalle committed Apr 24, 2022
1 parent 5d562ab commit c2014f7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
1 change: 0 additions & 1 deletion site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"directory": "site"
},
"private": true,
"main": "./source/entry-empty.js",
"engines": {
"node": ">=12.16.1"
},
Expand Down
1 change: 1 addition & 0 deletions site/prerender.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions site/source/entry-empty.js

This file was deleted.

15 changes: 7 additions & 8 deletions site/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c2014f7

Please sign in to comment.