How to use superstatic - 5 common examples

To help you get started, we’ve selected a few superstatic 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 loadingwyn / react-imageViewer / scripts / dev.js View on Github external
Object.assign(config, {
  mode: 'development',
  entry: './demo/demo.js',
  externals: [],
});
const compiler = webpack(config);
const ifaces = os.networkInterfaces();
let lookupIpAddress = null;

Object.values(ifaces).forEach(item => {
  const target = item.find(details => details.family === 'IPv4');
  if (target) {
    lookupIpAddress = target.address;
  }
});
const app = superstatic({
  host: lookupIpAddress,
  port: 8080,
});
compiler.watch({
  // Example watchOptions
  aggregateTimeout: 300,
  poll: undefined,
}, (err, stats) => {
  if (err || stats.hasErrors()) {
    console.log('Error!');
    if (err && err.details) {
      console.error(err.details);
    }
  }
});
github dexteryy / Project-WebCube / packages / webcube / configs / gulpfile.js View on Github external
function startStaticWebServer(done) {
  fs.writeFileSync(pidFile, process.pid);
  const config = jsonfile.readFileSync(
    path.join(modulePath, 'configs/superstatic.json')
  );
  let customConfig;
  try {
    customConfig = jsonfile.readFileSync(
      path.join(projectPath, 'configs/static.json')
    );
    delete customConfig.public;
  } catch (e) {
    //
  }
  staticWebServer
    .server({
      port: serverPort,
      host: serverHost,
      cwd: projectPath,
      config: Object.assign({}, config, customConfig),
      errorPage:
        process.env.WEBCUBE_STATIC_SERVER_ERROR_PAGE ||
        path.join(modulePath, 'templates/configs/404.html'),
      debug: Boolean(process.env.WEBCUBE_STATIC_SERVER_ENABLE_DEBUG),
      gzip: Boolean(process.env.WEBCUBE_STATIC_SERVER_ENABLE_GZIP),
    })
    .listen(() => {
      console.info(`Listening at http://${serverHost}:${serverPort}`);
      done();
    });
}
github firebase / firebase-tools / lib / serve / hosting.js View on Github external
function _startServer(options, config, port, init) {
  var server = superstatic({
    debug: true,
    port: port,
    host: options.host,
    config: config,
    cwd: detectProjectRoot(options.cwd),
    stack: "strict",
    before: {
      files: initMiddleware(init),
    },
    rewriters: {
      function: functionsProxy(options),
    },
  }).listen(function() {
    var siteName = config.target || config.site;
    var label = siteName ? "hosting[" + siteName + "]" : "hosting";
github divshot / divshot-cli / lib / commands / push.js View on Github external
var fs = require('fs');
var path = require('path');
var fstream = require('fstream');
var requestModule = require('request');
var tar = require('tar');
var zlib = require('zlib');
var http = require('http');
var eventStream = require('event-stream');
var fs = require('fs');
var ignoreGlobs = require('superstatic').ignore.globs;
var Ignore = require('fstream-ignore');
var file = require('file');
var through = require('through');
var minimatch = require('minimatch');
var TEN_MB = 10000000;

module.exports = function (app) {
  app.program
    .command('push')
    .description('deploy your app to the specified environment')
    .example('push [environment]')
    .option('-z, --zip ', 'upload a zip file instead of a tar (for testing/diagnostics)', readStream)
    .option('-f, --file ', 'PUT a single file (for testing/diagnostics)', readStream)
    .withAuth()
    .withConfig()
    .handler(function () {
github divshot / divshot-cli / lib / commands / push / deployment.js View on Github external
var _ = require('lodash');
var tarzan = require('tarzan');
var ignoreGlobs = require('superstatic').ignore.globs;

var Deployment = function (types, loadpoint, exclude) {
  this._types = types;
  this._loadpoint = loadpoint;
  this._exclude = exclude;
  
  this._requestOptions = {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/octet-stream',
      Authorization: this._loadpoint.authorization
    }
  };
};

Deployment.prototype.push = function (appRootDir) {

superstatic

A static file server for fancy apps

MIT
Latest version published 1 year ago

Package Health Score

78 / 100
Full package analysis

Popular superstatic functions