@@ -4,7 +4,7 @@ import react from "@vitejs/plugin-react-swc"
44import basicSsl from "@vitejs/plugin-basic-ssl"
55import glsl from "vite-plugin-glsl"
66import { loadEnv , ProxyOptions } from "vite"
7-
7+ import fs from "node:fs/promises"
88const basePath = "/fission/"
99const serverPort = 3000
1010const dockerServerPort = 80
@@ -37,34 +37,44 @@ if (useSsl) {
3737 plugins . push ( basicSsl ( ) )
3838}
3939
40+ const localAssetsExist = await fs . access ( "./public/Downloadables/Mira" , fs . constants . R_OK ) . then ( ( ) => true ) . catch ( ( ) => false )
41+
4042// https://vitejs.dev/config/
41- export default defineConfig ( ( { mode, } ) => {
43+ export default defineConfig ( ( { mode } ) => {
4244 process . env = { ...process . env , ...loadEnv ( mode , process . cwd ( ) ) } ;
43- const useLocalAssets = mode === "test" || process . env . DEV
45+
46+ const useLocalAssets = localAssetsExist && ( mode === "test" || process . env . NODE_ENV == "development" )
47+
48+ if ( ! localAssetsExist && ( mode === "test" || process . env . NODE_ENV == "development" ) ) {
49+ console . warn ( "Can't find local assets, do you need to run `npm run assetpack`?" )
50+ }
51+
52+ console . log ( `Using ${ useLocalAssets ?"local" :"remote" } mirabuf assets` )
53+
4454 const proxies : Record < string , ProxyOptions > = { }
4555 proxies [ "/api/mira" ] = useLocalAssets
4656 ? {
47- target : `http://localhost:${ mode === "test" ? 3001 : serverPort } ` ,
48- changeOrigin : true ,
49- secure : false ,
50- rewrite : path => path . replace ( / ^ \/ a p i \/ m i r a / , "/Downloadables/Mira" ) . replace ( "robots" , "Robots" ) . replace ( "fields" , "Fields" ) ,
51- }
57+ target : `http://localhost:${ mode === "test" ? 3001 : serverPort } ` ,
58+ changeOrigin : true ,
59+ secure : false ,
60+ rewrite : path => path . replace ( / ^ \/ a p i \/ m i r a / , "/Downloadables/Mira" ) . replace ( "robots" , "Robots" ) . replace ( "fields" , "Fields" ) ,
61+ }
5262 : {
53- target : `https://synthesis.autodesk.com/` ,
54- changeOrigin : true ,
55- secure : true ,
56- }
63+ target : `https://synthesis.autodesk.com/` ,
64+ changeOrigin : true ,
65+ secure : true ,
66+ }
5767 proxies [ "/api/aps" ] = useLocalAPS
5868 ? {
59- target : `http://localhost:${ dockerServerPort } /` ,
60- changeOrigin : true ,
61- secure : false ,
62- }
69+ target : `http://localhost:${ dockerServerPort } /` ,
70+ changeOrigin : true ,
71+ secure : false ,
72+ }
6373 : {
64- target : `https://synthesis.autodesk.com/` ,
65- changeOrigin : true ,
66- secure : true ,
67- }
74+ target : `https://synthesis.autodesk.com/` ,
75+ changeOrigin : true ,
76+ secure : true ,
77+ }
6878
6979 return {
7080 plugins : plugins ,
0 commit comments