How to use the hops-config.locations function in hops-config

To help you get started, we’ve selected a few hops-config examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xing / hops / packages / build / lib / generate.js View on Github external
module.exports = function(webpackConfig) {
  var render = createRenderer(webpackConfig);
  return Promise.all(
    (hopsConfig.locations || []).map(function(location) {
      return render(location).then(function(html) {
        if (html) {
          return writeFile(location, html);
        }
      });
    })
  ).then(function() {
    console.log(/* empty line */);
  });
};
github xing / hops / packages / express / lib / utils.js View on Github external
exports.rewritePath = function rewritePath(req, res, next) {
  if (
    process.env.HOPS_MODE === 'static' &&
    Array.isArray(hopsConfig.locations)
  ) {
    var location = hopsConfig.locations.find(function(location) {
      return (
        location !== hopsConfig.basePath + '/' &&
        req.url.indexOf(location) === 0
      );
    });
    if (location) {
      req.url = location.replace(/([^\\/])$/, '$1/');
    }
  }
  next();
};
github xing / hops / packages / server / index.js View on Github external
exports.registerMiddleware = function registerMiddleware(app, middleware) {
  if (
    process.env.HOPS_MODE === 'static' &&
    Array.isArray(hopsConfig.locations)
  ) {
    hopsConfig.locations.forEach(function(location) {
      app.get(location === '/' ? location : location + '*', middleware);
    });
  } else {
    app.all('*', middleware);
  }
};
github xing / hops / packages / server / index.js View on Github external
exports.registerMiddleware = function registerMiddleware(app, middleware) {
  if (
    process.env.HOPS_MODE === 'static' &&
    Array.isArray(hopsConfig.locations)
  ) {
    hopsConfig.locations.forEach(function(location) {
      app.get(location === '/' ? location : location + '*', middleware);
    });
  } else {
    app.all('*', middleware);
  }
};
github xing / hops / packages / express / lib / utils.js View on Github external
exports.rewritePath = function rewritePath(req, res, next) {
  if (
    process.env.HOPS_MODE === 'static' &&
    Array.isArray(hopsConfig.locations)
  ) {
    var location = hopsConfig.locations.find(function(location) {
      return (
        location !== hopsConfig.basePath + '/' &&
        req.url.indexOf(location) === 0
      );
    });
    if (location) {
      req.url = location.replace(/([^\\/])$/, '$1/');
    }
  }
  next();
};
github xing / hops / packages / express / lib / utils.js View on Github external
exports.registerMiddleware = function registerMiddleware(app, middleware) {
  app.use(exports.assetsMiddleware);
  if (
    process.env.HOPS_MODE === 'static' &&
    Array.isArray(hopsConfig.locations)
  ) {
    hopsConfig.locations.forEach(function(location) {
      app.get(location === '/' ? location : location + '*', middleware);
    });
  } else {
    app.all('*', middleware);
  }
};
github xing / hops / packages / server / index.js View on Github external
exports.rewritePath = function rewritePath(req, res, next) {
  if (
    process.env.HOPS_MODE === 'static' &&
    Array.isArray(hopsConfig.locations)
  ) {
    var location = hopsConfig.locations.find(function(location) {
      return (
        location !== hopsConfig.basePath + '/' &&
        req.url.indexOf(location) === 0
      );
    });
    if (location) {
      req.url = location.replace(/([^\\/])$/, '$1/');
    }
  }
  next();
};