How to use the hops-config.buildDir 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
function createApp(options) {
  var app = express();
  app.use(utils.timings);
  app.use(helmet());
  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(
github xing / hops / packages / build / lib / generate.js View on Github external
return new Promise(function(resolve, reject) {
    var filename = getFileName(location);
    console.log(
      filename.replace(hopsConfig.buildDir, ''),
      filesize(Buffer.byteLength(html))
    );
    mkdirp(path.dirname(filename), function(err) {
      if (err) {
        reject(err);
      } else {
        fs.writeFile(filename, html, function(err) {
          err ? reject(err) : resolve();
        });
      }
    });
  });
}
github xing / hops / packages / build-config / configs / build.js View on Github external
var StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin;
var ServiceWorkerPlugin = require('../plugins/service-worker');
var MiniCSSExtractPlugin = require('mini-css-extract-plugin');
var UglifyJSPlugin = require('uglifyjs-webpack-plugin');
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');

var hopsConfig = require('hops-config');

var getAssetPath = path.join.bind(path, hopsConfig.assetPath);

module.exports = {
  mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
  bail: true,
  entry: require.resolve('../shims/build'),
  output: {
    path: hopsConfig.buildDir,
    publicPath: '/',
    pathinfo: true,
    filename: getAssetPath('[name]-[chunkhash:16].js'),
    chunkFilename: getAssetPath('[name]-[chunkhash:16].js'),
    devtoolModuleFilenameTemplate: function(info) {
      return path
        .relative(hopsConfig.appDir, info.absoluteResourcePath)
        .replace(/\\/g, '/');
    },
  },
  context: hopsConfig.appDir,
  resolve: require('../sections/resolve')('build'),
  module: {
    rules: require('../sections/module-rules')('build'),
  },
  devtool: 'source-map',
github xing / hops / packages / build-config / configs / build.js View on Github external
var webpack = require('webpack');
var StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin;
var ServiceWorkerPlugin = require('../plugins/service-worker');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

var hopsConfig = require('hops-config');

var getAssetPath = path.join.bind(path, hopsConfig.assetPath);

module.exports = {
  mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
  bail: true,
  entry: require.resolve('../shims/build'),
  output: {
    path: hopsConfig.buildDir,
    publicPath: '/',
    pathinfo: true,
    filename: getAssetPath('[name]-[chunkhash:16].js'),
    chunkFilename: getAssetPath('[name]-[chunkhash:16].js'),
    devtoolModuleFilenameTemplate: function(info) {
      return path
        .relative(hopsConfig.appDir, info.absoluteResourcePath)
        .replace(/\\/g, '/');
    },
  },
  context: hopsConfig.appDir,
  resolve: require('../sections/resolve')('build'),
  module: {
    rules: require('../sections/module-rules')('build'),
  },
  devtool: 'source-map',
github xing / hops / packages / build-config / configs / develop.js View on Github external
var webpack = require('webpack');

var ServiceWorkerPlugin = require('../plugins/service-worker');

var hopsConfig = require('hops-config');

var getAssetPath = path.join.bind(path, hopsConfig.assetPath);

module.exports = {
  mode: 'development',
  entry: [
    require.resolve('webpack-hot-middleware/client'),
    require.resolve('../shims/develop'),
  ],
  output: {
    path: hopsConfig.buildDir,
    publicPath: '/',
    pathinfo: true,
    filename: getAssetPath('[name].js'),
    chunkFilename: getAssetPath('chunk-[id].js'),
    devtoolModuleFilenameTemplate: function(info) {
      return path.resolve(info.absoluteResourcePath).replace(/\\/g, '/');
    },
  },
  context: hopsConfig.appDir,
  resolve: require('../sections/resolve')('develop'),
  module: {
    rules: require('../sections/module-rules')('develop'),
  },
  plugins: [
    new ServiceWorkerPlugin(),
    new webpack.HotModuleReplacementPlugin(),
github xing / hops / packages / express / lib / utils.js View on Github external
function getStatsFromFile() {
  if (!stats) {
    var statsFilename = path.join(hopsConfig.buildDir, 'stats.json');
    if (fs.existsSync(statsFilename)) {
      stats = require(statsFilename);
    }
  }
  return stats || {};
}
github xing / hops / packages / build / lib / server.js View on Github external
function runDevelop(options, callback) {
  var compiler = webpack(developConfig);
  var app = express();
  app.use(hopsExpressUtils.timings);
  app.use(
    webpackDevMiddleware(compiler, {
      noInfo: true,
      logLevel: 'warn',
      publicPath: developConfig.output.publicPath,
      watchOptions: developConfig.watchOptions,
      serverSideRender: true,
    })
  );
  app.use(webpackHotMiddleware(compiler));
  app.use(hopsExpressUtils.rewritePath);
  app.use(express.static(hopsConfig.buildDir, { redirect: false }));
  hopsExpressUtils.bootstrap(app, hopsConfig);
  hopsExpressUtils.registerMiddleware(
    app,
    createMiddleware(
      nodeConfig,
      nodeConfig.watchOptions || developConfig.watchOptions
    )
  );
  hopsExpressUtils.teardown(app, hopsConfig);
  hopsExpressUtils.run(app, callback);
}