chore: close plugin

This commit is contained in:
Danny Avila 2024-08-28 11:33:23 -04:00
parent be2abf09cc
commit 08d2a88e70
No known key found for this signature in database
GPG key ID: 2DD9CC89B9B50364
2 changed files with 24 additions and 0 deletions

View file

@ -0,0 +1,22 @@
export default function ClosePlugin() {
return {
name: 'ClosePlugin', // required, will show up in warnings and errors
// use this to catch errors when building
buildEnd(error) {
if(error) {
console.error('Error bundling')
console.error(error)
process.exit(1)
} else {
console.log('Build ended')
}
},
// use this to catch the end of a build without errors
closeBundle(id) {
console.log('Bundle closed')
process.exit(0)
},
}
}

View file

@ -4,6 +4,7 @@ import { VitePWA } from 'vite-plugin-pwa';
import { defineConfig, createLogger } from 'vite';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import type { Plugin } from 'vite';
import ClosePlugin from './vite-plugin-close.ts'
const logger = createLogger();
const originalWarning = logger.warn;
@ -51,6 +52,7 @@ export default defineConfig({
envDir: '../',
envPrefix: ['VITE_', 'SCRIPT_', 'DOMAIN_', 'ALLOW_'],
plugins: [
ClosePlugin(),
react(),
nodePolyfills(),
VitePWA({