server: use "/usr/share/flood/assets" as a location of assets

This commit is contained in:
Jesse Chan
2021-01-19 10:34:12 +08:00
parent c279760160
commit f3ebdece95

View File

@@ -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;
};