11import react from "@vitejs/plugin-react-swc" ;
22import { defineConfig } from "vite" ;
3+ import { resolve } from 'path' ;
4+ import fs from 'fs-extra' ;
5+
6+ // Custom plugin to copy specific files from public
7+ const copySpecificFiles = ( ) => ( {
8+ name : 'copy-specific-files' ,
9+ closeBundle : async ( ) => {
10+ const filesToCopy = [
11+ 'manifest.json' ,
12+ 'robots.txt' ,
13+ 'logo.svg' ,
14+ 'deepgit_logo.png' ,
15+ 'dxl_logo.png' ,
16+ 'ossci_logo.jpg'
17+ ] ;
18+
19+ for ( const file of filesToCopy ) {
20+ const sourcePath = resolve ( __dirname , 'public' , file ) ;
21+ const targetPath = resolve ( __dirname , 'dist' , file ) ;
22+ if ( fs . existsSync ( sourcePath ) ) {
23+ await fs . copy ( sourcePath , targetPath ) ;
24+ }
25+ }
26+ }
27+ } ) ;
328
429console . log ( `Building DeepGit with BASE_PATH="${ process . env . BASE_PATH || "/" } "` ) ;
530
631export default defineConfig ( {
732 base : process . env . BASE_PATH || "/" ,
8- plugins : [ react ( ) ] ,
33+ plugins : [
34+ react ( ) ,
35+ copySpecificFiles ( )
36+ ] ,
937 server : {
1038 host : "0.0.0.0" ,
1139 port : process . env . PORT ? parseInt ( process . env . PORT ) : 5173 ,
@@ -17,5 +45,18 @@ export default defineConfig({
1745 port : process . env . PORT ? parseInt ( process . env . PORT ) : 5173 ,
1846 allowedHosts : [ "deepgit.onrender.com" ]
1947 } ,
48+ // Disable automatic public directory copying
49+ publicDir : false ,
50+ // Manually copy only specific files from public
51+ build : {
52+ rollupOptions : {
53+ input : {
54+ main : resolve ( __dirname , 'index.html' ) ,
55+ } ,
56+ } ,
57+ // Copy only specific files from public
58+ copyPublicDir : true ,
59+ assetsInlineLimit : 0 ,
60+ } ,
2061} ) ;
2162
0 commit comments