The code powering m.abunchtell.com https://m.abunchtell.com
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

36 rader
1.0 KiB

  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. function removeOuterSlashes(string) {
  10. return string.replace(/^\/*/, '').replace(/\/*$/, '');
  11. }
  12. function formatPublicPath(host = '', path = '') {
  13. let formattedHost = removeOuterSlashes(host);
  14. if (formattedHost && !/^http/i.test(formattedHost)) {
  15. formattedHost = `//${formattedHost}`;
  16. }
  17. const formattedPath = removeOuterSlashes(path);
  18. return `${formattedHost}/${formattedPath}/`;
  19. }
  20. const output = {
  21. path: resolve('public', settings.public_output_path),
  22. publicPath: formatPublicPath(env.ASSET_HOST, settings.public_output_path),
  23. };
  24. module.exports = {
  25. settings,
  26. env,
  27. loadersDir,
  28. output,
  29. };