mon-entreprise/site/build/vite-iframe-script.config.ts

43 lines
1002 B
TypeScript
Raw Permalink Normal View History

import { statSync } from 'fs'
2023-02-01 00:28:35 +00:00
import path from 'path'
2023-06-15 13:57:48 +00:00
import yaml from '@rollup/plugin-yaml'
2022-01-28 09:20:54 +00:00
import { defineConfig } from 'vite'
2023-02-01 00:28:35 +00:00
import { VitePWA } from 'vite-plugin-pwa'
2022-01-28 09:20:54 +00:00
export default defineConfig({
2023-02-01 00:28:35 +00:00
resolve: {
alias: [{ find: '@', replacement: path.resolve('./source') }],
},
2022-01-28 09:20:54 +00:00
build: {
lib: {
entry: './source/entries/entry-iframe.ts',
2022-01-28 09:20:54 +00:00
name: 'monEntrepriseIframe',
formats: ['iife'],
2022-06-27 08:20:36 +00:00
fileName: () => 'simulateur-iframe-integration.js',
2022-01-28 09:20:54 +00:00
},
emptyOutDir: false,
},
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)
},
},
],
2022-01-28 09:20:54 +00:00
})