How to use the @sanity/server.getDevServer function in @sanity/server

To help you get started, we’ve selected a few @sanity/server 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 sanity-io / sanity / packages / @sanity / core / src / actions / start / startAction.js View on Github external
staticPath: resolveStaticPath(workDir, config),
    basePath: workDir,
    httpHost,
    httpPort,
    context,
    project: sanityConfig.get('project')
  }

  checkStudioDependencyVersions(workDir)

  let compileSpinner
  const configSpinner = output.spinner('Checking configuration files...')
  await tryInitializePluginConfigs({workDir, output, env: 'development'})
  configSpinner.succeed()

  const server = getDevServer(serverOptions)
  const compiler = server.locals.compiler

  // "invalid" doesn't mean the bundle is invalid, but that it is *invalidated*,
  // in other words, it's recompiling
  compiler.plugin('invalid', () => {
    output.clear()
    resetSpinner()
  })

  // Start the server and try to create more user-friendly errors if we encounter issues
  try {
    await promisify(server.listen.bind(server))(httpPort, httpHost)
  } catch (err) {
    gracefulDeath(httpHost, config, err)
  }