From c71b91b68f0e0d0499957c8629fbea7a8208abad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Mon, 6 Feb 2023 11:32:25 +0100 Subject: [PATCH] Add delay in postbuild-commands --- site/vite-build-simulation-data.config.ts | 47 ++++++++++++----------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/site/vite-build-simulation-data.config.ts b/site/vite-build-simulation-data.config.ts index 7d4ae6857..5a2d0158c 100644 --- a/site/vite-build-simulation-data.config.ts +++ b/site/vite-build-simulation-data.config.ts @@ -37,31 +37,34 @@ export default defineConfig({ }, { name: 'postbuild-commands', - closeBundle: async () => { - const path = './builded-simulation-data.js' - type PageConfigType = { - default: Record> - } - const algoliaUpdate = ((await import(path)) as PageConfigType).default + closeBundle: () => { + // eslint-disable-next-line @typescript-eslint/no-misused-promises + setTimeout(async () => { + const path = './builded-simulation-data.js' + type PageConfigType = { + default: Record> + } + const algoliaUpdate = ((await import(path)) as PageConfigType).default - unlinkSync(path) - writeFileSync( - './source/public/simulation-data.json', - JSON.stringify(algoliaUpdate) - ) - writeFileSync( - './source/public/simulation-data-title.json', - JSON.stringify( - Object.fromEntries( - Object.entries(algoliaUpdate).map(([id, { title }]) => [ - id, - { title }, - ]) + unlinkSync(path) + writeFileSync( + './source/public/simulation-data.json', + JSON.stringify(algoliaUpdate) + ) + writeFileSync( + './source/public/simulation-data-title.json', + JSON.stringify( + Object.fromEntries( + Object.entries(algoliaUpdate).map(([id, { title }]) => [ + id, + { title }, + ]) + ) ) ) - ) - // eslint-disable-next-line no-console - console.log('done!') + // eslint-disable-next-line no-console + console.log('done!') + }, 1000) }, }, ],