diff --git a/src/lib/functions/autoCloseViteBuild.ts b/src/lib/functions/autoCloseViteBuild.ts new file mode 100644 index 0000000..6079622 --- /dev/null +++ b/src/lib/functions/autoCloseViteBuild.ts @@ -0,0 +1,23 @@ +import type { PluginOption } from 'vite'; + +export default function closePlugin() { + const plugin: PluginOption = { + name: 'BuildWatcher', + buildEnd: function (error?: Error) { + if (error) { + console.error('\x1b[35m[BuildWatcher]\x1b[0m Error building.'); + console.error(error); + process.exit(1); + } else { + console.log('\x1b[35m[BuildWatcher]\x1b[0m Build Stage Ended.'); + } + }, + + closeBundle: function () { + console.log('\x1b[35m[BuildWatcher]\x1b[0m Bundle closed'); + process.exit(0); + }, + }; + + return plugin; +} diff --git a/vite.config.ts b/vite.config.ts index 5f91bb8..41c30ec 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,10 +1,12 @@ import { sveltekit } from '@sveltejs/kit/vite'; import { defineConfig } from 'vite'; import { startupSocketIOServer } from './src/lib/functions/websocketConfig'; +import closePlugin from './src/lib/functions/autoCloseViteBuild'; export default defineConfig({ plugins: [ sveltekit(), + closePlugin(), { name: 'integratedSocketIOServer', configureServer(server) {