logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

configuration.js (1146B)


  1. // Common configuration for webpacker loaded from config/webpacker.yml
  2. const { join, resolve } = require('path');
  3. const { env } = require('process');
  4. const { safeLoad } = require('js-yaml');
  5. const { readFileSync } = require('fs');
  6. const configPath = resolve('config', 'webpacker.yml');
  7. const loadersDir = join(__dirname, 'loaders');
  8. const settings = safeLoad(readFileSync(configPath), 'utf8')[env.NODE_ENV];
  9. const themePath = resolve('config', 'themes.yml');
  10. const themes = safeLoad(readFileSync(themePath), 'utf8');
  11. function removeOuterSlashes(string) {
  12. return string.replace(/^\/*/, '').replace(/\/*$/, '');
  13. }
  14. function formatPublicPath(host = '', path = '') {
  15. let formattedHost = removeOuterSlashes(host);
  16. if (formattedHost && !/^http/i.test(formattedHost)) {
  17. formattedHost = `//${formattedHost}`;
  18. }
  19. const formattedPath = removeOuterSlashes(path);
  20. return `${formattedHost}/${formattedPath}/`;
  21. }
  22. const output = {
  23. path: resolve('public', settings.public_output_path),
  24. publicPath: formatPublicPath(env.CDN_HOST, settings.public_output_path),
  25. };
  26. module.exports = {
  27. settings,
  28. themes,
  29. env,
  30. loadersDir,
  31. output,
  32. };