Add script post build to check size of integration script is not too big

pull/2573/head
Jérémy Rialland 2023-04-06 19:18:32 +02:00 committed by Jérémy Rialland
parent a553c30c01
commit 025a6ed89a
1 changed files with 22 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import yaml from '@rollup/plugin-yaml'
import { statSync } from 'fs'
import path from 'path'
import { defineConfig } from 'vite'
import { VitePWA } from 'vite-plugin-pwa'
@ -16,5 +17,25 @@ export default defineConfig({
},
emptyOutDir: false,
},
plugins: [yaml(), VitePWA({ disable: true })],
plugins: [
yaml(),
VitePWA({ disable: true }),
{
name: 'postbuild-commands',
closeBundle: () => {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
setTimeout(() => {
const path = './dist/simulateur-iframe-integration.js'
const stats = statSync(path)
const limit = 5000
if (stats.size > limit) {
console.error(
`Failed to build ${path}, the built file looks too big! (${stats.size} > ${limit})`
)
}
}, 1000)
},
},
],
})