From f3ebdece950e8022dccf7436e6034c6f7df8a8ef Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Tue, 19 Jan 2021 10:34:12 +0800 Subject: [PATCH] server: use "/usr/share/flood/assets" as a location of assets --- shared/config/paths.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/shared/config/paths.js b/shared/config/paths.js index 33a54613..f06931e4 100644 --- a/shared/config/paths.js +++ b/shared/config/paths.js @@ -19,14 +19,20 @@ const ensureSlash = (questionablePath, needsSlash) => { const getAppDist = () => { // In production, assets are in assets/. - const appDist = path.resolve(path.join(__dirname, 'assets')); + let appDist = path.resolve(path.join(__dirname, 'assets')); + if (!fs.existsSync(appDist)) { // In development, assets are in ${appDirectory}/dist/assets/. - const appBuild = resolveApp('dist/assets'); - if (fs.existsSync(appBuild)) { - return appBuild; - } + appDist = resolveApp('dist/assets'); } + + if (!fs.existsSync(appDist)) { + // Assets are placed to /usr when Flood is managed by package + // managers other than npm. This allows users to serve static + // assets from web server directly if they want. + appDist = path.resolve('/usr/share/flood/assets'); + } + return appDist; };