How to use the @sanity/server.ReactDOM.renderToStaticMarkup 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 / build / buildStaticAssets.js View on Github external
{...compilationConfig, hashes: chunkMap},
      {
        scripts: ['vendor.bundle.js', 'app.bundle.js'].map(asset => {
          const assetPath = absoluteMatch.test(asset) ? asset : `js/${asset}`
          return {
            path: assetPath,
            hash: chunkMap[assetPath] || chunkMap[asset]
          }
        })
      }
    )

    // Write index file to output destination
    await fse.writeFile(
      path.join(outputDir, 'index.html'),
      `${ReactDOM.renderToStaticMarkup(doc)}`
    )

    // Print build output, optionally stats if requested
    bundle.stats.warnings.forEach(output.print)
    spin.text = `Building index document (${Date.now() - indexStart}ms)`
    spin.succeed()

    if (flags.stats) {
      output.print('\nLargest modules (unminified, uncompressed sizes):')
      sortModulesBySize(bundle.stats.modules)
        .slice(0, 10)
        .forEach(module => output.print(`[${filesize(module.size)}] ${module.name}`))
    }

    // Now compress the JS bundles
    if (!compilationConfig.skipMinify) {
github sanity-io / sanity / packages / @sanity / cli / src / commands / build / buildCommand.js View on Github external
.then(doc =>
        fsp.writeFile(
          path.join(outputDir, 'index.html'),
          `${ReactDOM.renderToStaticMarkup(doc)}`
        )
      )