File tree Expand file tree Collapse file tree 3 files changed +6619
-3833
lines changed Expand file tree Collapse file tree 3 files changed +6619
-3833
lines changed Original file line number Diff line number Diff line change 11import { defineConfig , loadEnv } from "vite" ;
22import { resolve } from "path" ;
3+ import { existsSync } from "fs" ;
34import { viteStaticCopy } from "vite-plugin-static-copy" ;
45import react from "@vitejs/plugin-react" ;
56import tailwindcss from "@tailwindcss/vite" ;
@@ -18,6 +19,29 @@ export default defineConfig(({ mode }) => {
1819 ? env . VITE_ALLOWED_HOSTS . split ( "," ) . map ( ( host ) => host . trim ( ) )
1920 : [ "localhost" ] ;
2021
22+ // Check if output directory exists
23+ const outputDirPath = resolve ( __dirname , "../output" ) ;
24+ const hasOutputDir = existsSync ( outputDirPath ) ;
25+
26+ // Build plugins array
27+ const plugins = [ react ( ) , tailwindcss ( ) ] ;
28+
29+ // Only add static copy plugin if output directory exists
30+ if ( hasOutputDir ) {
31+ plugins . push (
32+ viteStaticCopy ( {
33+ targets : [
34+ {
35+ src : "../output/**/*" ,
36+ dest : "output" ,
37+ } ,
38+ ] ,
39+ } )
40+ ) ;
41+ } else {
42+ console . log ( "Output directory not found, skipping static copy" ) ;
43+ }
44+
2145 return {
2246 server : {
2347 port : 3000 ,
@@ -46,18 +70,6 @@ export default defineConfig(({ mode }) => {
4670 env : processEnvVars ,
4771 } ) ,
4872 } ,
49- // assetsInclude: ['../output/**/*']
50- plugins : [
51- react ( ) ,
52- tailwindcss ( ) ,
53- viteStaticCopy ( {
54- targets : [
55- {
56- src : "../output/**/*" ,
57- dest : "output" ,
58- } ,
59- ] ,
60- } ) ,
61- ] ,
73+ plugins,
6274 } ;
6375} ) ;
You can’t perform that action at this time.
0 commit comments