V2 fix offline (#294)

* fix: resolve path to UI build in dev

* fix: configure offline fetching
This commit is contained in:
Carlos Valente
2023-02-23 21:10:41 +01:00
committed by GitHub
parent 70cc071425
commit 03552056cb
11 changed files with 46 additions and 72 deletions
+6 -3
View File
@@ -8,7 +8,7 @@ import { join, resolve } from 'path';
import { initiateOSC, shutdownOSCServer } from './controllers/OscController.js';
import { initSentry } from './modules/sentry.js';
import { currentDirectory, environment, isProduction, resolvedPath, uiPath } from './setup.js';
import { currentDirectory, environment, isProduction, resolvedPath } from './setup.js';
import { ONTIME_VERSION } from './ONTIME_VERSION.js';
import { OSCSettings } from 'ontime-types';
@@ -62,10 +62,13 @@ app.use('/playback', playbackRouter);
app.use('/external', express.static(join(currentDirectory, 'external')));
// serve static - react, in test mode we fetch the React app from module
app.use(express.static(join(currentDirectory, resolvedPath(), uiPath)));
const newpath = join(currentDirectory, resolvedPath());
console.log('serving content at ', newpath);
app.use(express.static(join(currentDirectory, resolvedPath())));
app.get('*', (req, res) => {
res.sendFile(resolve(currentDirectory, resolvedPath(), uiPath, 'index.html'));
res.sendFile(resolve(currentDirectory, resolvedPath(), 'index.html'));
});
// Implement catch all
+2 -3
View File
@@ -40,10 +40,9 @@ export const isProduction = env === 'production' && !isTest;
// =================================================
// resolve path to external
const productionPath = '../../Resources/extraResources/';
const devPath = '../../';
const productionPath = '../../Resources/extraResources/client';
const devPath = '../../client/build/';
export const uiPath = 'client/';
export const resolvedPath = (): string => (isProduction ? productionPath : devPath);
// resolve file URL in both CJS and ESM (build and dev)