How to use the hops-config.cacheDir 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 / express / lib / app.js View on Github external
app.use(compression());
  app.use(utils.rewritePath);
  app.use(
    express.static(hopsConfig.buildDir, {
      maxAge: '1y',
      setHeaders: function(res, filepath) {
        if (mime.getType(filepath) === 'text/html' || filepath.match(swRe)) {
          helmet.noCache()(null, res, function() {});
        }
      },
      redirect: false,
    })
  );
  utils.bootstrap(app, hopsConfig);
  if (options && !options.static) {
    var filePath = path.join(hopsConfig.cacheDir, 'server.js');
    if (fs.existsSync(filePath)) {
      utils.registerMiddleware(app.use(helmet.noCache()), require(filePath));
    } else {
      console.log(
        'No middleware found. Delivering only statically built routes.'
      );
    }
  }
  utils.teardown(app, hopsConfig);
  return app;
}
github xing / hops / packages / build-config / configs / node.js View on Github external
module.indexOf('hops') === 0 ||
    module.indexOf('core-js') === 0 ||
    module.indexOf('babel-polyfill') === 0 ||
    !/\.(?:js|json|mjs|node)$/.test(require.resolve(module)) ||
    checkEsnext(module)
  );
}

var modulesDir = findNodeModules(process.cwd());

module.exports = {
  target: 'node',
  mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
  entry: require.resolve('../shims/node'),
  output: {
    path: hopsConfig.cacheDir,
    publicPath: '/',
    pathinfo: true,
    filename: 'server.js',
    libraryTarget: 'commonjs2',
    devtoolModuleFilenameTemplate: function(info) {
      return path.resolve(info.absoluteResourcePath).replace(/\\/g, '/');
    },
  },
  context: hopsConfig.appDir,
  resolve: require('../sections/resolve')('node'),
  externals: [
    require('webpack-node-externals')({
      modulesDir: modulesDir,
      whitelist: shouldIncludeExternalModuleInBundle,
    }),
  ],
github xing / hops / packages / build-config / plugins / write-file.js View on Github external
assetKeys.reduce(function(result, assetKey) {
          if (regExp.test(assetKey)) {
            var fileName = path.resolve(hopsConfig.cacheDir, assetKey);
            var fileContent = compilation.assets[assetKey].source();
            delete compilation.assets[assetKey];
            result.push(
              new Promise(function(resolve, reject) {
                mkdirp.sync(hopsConfig.cacheDir);
                fs.writeFile(fileName, fileContent, function(err) {
                  err ? reject(err) : resolve();
                });
              })
            );
          }
          return result;
        }, [])
      )
github xing / hops / packages / build / lib / build.js View on Github external
module.exports = function runBuild(options, callback) {
  var build = getBuildFunction(options, callback);
  if (options.clean) {
    var dirs = [hopsConfig.buildDir, hopsConfig.cacheDir];
    return cleanup(dirs).then(build);
  } else {
    return build();
  }
};
github xing / hops / packages / build / lib / server.js View on Github external
module.exports = function(options, callback) {
  if (options.clean) {
    var dirs = [hopsConfig.buildDir, hopsConfig.cacheDir];
    return cleanup(dirs).then(runDevelop.bind(null, options, callback));
  } else {
    return runDevelop(options, callback);
  }
};
github xing / hops / packages / build-config / plugins / write-manifest.js View on Github external
assets.css.push('/' + assetPath);
          }
          if (path.extname(assetPath) === '.js') {
            if (assetPath.indexOf('vendor-') >= 0) {
              assets.js.unshift('/' + assetPath);
            } else {
              assets.js.push('/' + assetPath);
            }
          }
          return assets;
        },
        { css: [], js: [] }
      );
      var fileName = path.resolve(hopsConfig.cacheDir, 'manifest.json');
      var fileContent = JSON.stringify(assets, null, 2);
      mkdirp.sync(hopsConfig.cacheDir);
      fs.writeFile(fileName, fileContent, callback);
    });
  };
github xing / hops / packages / build-config / plugins / write-file.js View on Github external
new Promise(function(resolve, reject) {
                mkdirp.sync(hopsConfig.cacheDir);
                fs.writeFile(fileName, fileContent, function(err) {
                  err ? reject(err) : resolve();
                });
              })
            );
github xing / hops / packages / build-config / plugins / write-manifest.js View on Github external
}
          if (path.extname(assetPath) === '.css') {
            assets.css.push('/' + assetPath);
          }
          if (path.extname(assetPath) === '.js') {
            if (assetPath.indexOf('vendor-') >= 0) {
              assets.js.unshift('/' + assetPath);
            } else {
              assets.js.push('/' + assetPath);
            }
          }
          return assets;
        },
        { css: [], js: [] }
      );
      var fileName = path.resolve(hopsConfig.cacheDir, 'manifest.json');
      var fileContent = JSON.stringify(assets, null, 2);
      mkdirp.sync(hopsConfig.cacheDir);
      fs.writeFile(fileName, fileContent, callback);
    });
  };