1- import { defineConfig } from "vite" ;
1+ import { defineConfig , Plugin } from "vite" ;
22import react from "@vitejs/plugin-react" ;
33import { viteSingleFile } from "vite-plugin-singlefile" ;
44import { resolve } from "path" ;
@@ -10,10 +10,30 @@ if (!app) {
1010 throw new Error ( "APP environment variable must be set" ) ;
1111}
1212
13+ // Plugin to rename the output file and remove the nested directory structure
14+ function renameOutput ( ) : Plugin {
15+ return {
16+ name : "rename-output" ,
17+ enforce : "post" ,
18+ generateBundle ( _ , bundle ) {
19+ // Find the HTML file and rename it
20+ for ( const fileName of Object . keys ( bundle ) ) {
21+ if ( fileName . endsWith ( "index.html" ) ) {
22+ const chunk = bundle [ fileName ] ;
23+ chunk . fileName = `${ app } .html` ;
24+ delete bundle [ fileName ] ;
25+ bundle [ `${ app } .html` ] = chunk ;
26+ break ;
27+ }
28+ }
29+ } ,
30+ } ;
31+ }
32+
1333export default defineConfig ( {
14- plugins : [ react ( ) , viteSingleFile ( ) ] ,
34+ plugins : [ react ( ) , viteSingleFile ( ) , renameOutput ( ) ] ,
1535 build : {
16- outDir : "dist" ,
36+ outDir : resolve ( __dirname , "../pkg/github/ui_dist" ) ,
1737 emptyOutDir : false ,
1838 rollupOptions : {
1939 input : resolve ( __dirname , `src/apps/${ app } /index.html` ) ,
0 commit comments