How to use the superstatic.server function in superstatic

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";

superstatic

A static file server for fancy apps

MIT
Latest version published 1 year ago

Package Health Score

76 / 100
Full package analysis

Popular superstatic functions