mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
* initial work * new client: working navigation and tasks showing up * finish header menu and add avatar component * fix sprites in new client * initial header version * initial styling for top menu * more progress on the header menu * almost complete menu and avatar * correctly apply active class for /social and /help * fix header colors and simplify css * switch from Roboto to native fonts * remove small avatar and add viewport * fixes * fix user menu with and progress bars * fix avatar rendeting * move bars colors to theme * add site overrides * fix tests * shrinkwrap * fix sprites path * another try at fixing the sprites path * another try at fixing the sprites path
30 lines
1.4 KiB
JavaScript
30 lines
1.4 KiB
JavaScript
import express from 'express';
|
|
import nconf from 'nconf';
|
|
import path from 'path';
|
|
|
|
const IS_PROD = nconf.get('IS_PROD');
|
|
const IS_NEW_CLIENT_ENABLED = nconf.get('NEW_CLIENT_ENABLED') === 'true';
|
|
const MAX_AGE = IS_PROD ? 31536000000 : 0;
|
|
const ASSETS_DIR = path.join(__dirname, '/../../assets');
|
|
const PUBLIC_DIR = path.join(__dirname, '/../../client-old');
|
|
const BUILD_DIR = path.join(__dirname, '/../../build');
|
|
|
|
module.exports = function staticMiddleware (expressApp) {
|
|
// Expose static files for new client
|
|
if (IS_PROD && IS_NEW_CLIENT_ENABLED) {
|
|
expressApp.use('/new-app/static', express.static(`${PUBLIC_DIR}/../../dist-client/static`));
|
|
}
|
|
|
|
// TODO move all static files to a single location (one for public and one for build)
|
|
expressApp.use(express.static(BUILD_DIR, { maxAge: MAX_AGE }));
|
|
// TODO figure out better way to set up sprites assets
|
|
expressApp.use('/static/sprites', express.static(`${ASSETS_DIR}/sprites/dist`, { maxAge: MAX_AGE }));
|
|
// so we have access to the gif sprites
|
|
expressApp.use(express.static(`${ASSETS_DIR}/sprites/backer-only/`, { maxAge: MAX_AGE }));
|
|
expressApp.use(express.static(`${ASSETS_DIR}/sprites/`, { maxAge: MAX_AGE }));
|
|
|
|
expressApp.use('/assets/audio', express.static(`${ASSETS_DIR}/audio`, { maxAge: MAX_AGE }));
|
|
expressApp.use('/assets/img', express.static(`${PUBLIC_DIR}/../../website/assets/img`, { maxAge: MAX_AGE }));
|
|
expressApp.use(express.static(PUBLIC_DIR));
|
|
};
|