How to use the @sanity/util/lib/getConfig function in @sanity/util

To help you get started, we’ve selected a few @sanity/util 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
export default async (args, context) => {
  const overrides = args.overrides || {}
  const {output, prompt, workDir} = context
  const flags = Object.assign(
    {minify: true, profile: false, stats: false, 'source-maps': false},
    args.extOptions
  )

  const unattendedMode = flags.yes || flags.y
  const defaultOutputDir = path.resolve(path.join(workDir, 'dist'))
  const outputDir = path.resolve(args.argsWithoutOptions[0] || defaultOutputDir)
  const config = getConfig(workDir, {env: 'production'})
  const compilationConfig = {
    env: 'production',
    staticPath: resolveStaticPath(workDir, config.get('server')),
    basePath: workDir,
    outputPath: path.join(outputDir, 'static'),
    sourceMaps: flags['source-maps'],
    skipMinify: !flags.minify,
    profile: flags.profile,
    project: Object.assign({}, config.get('project'), overrides.project)
  }

  await tryInitializePluginConfigs({workDir, output, env: 'production'})

  checkStudioDependencyVersions(workDir)

  const envVars = webpackIntegration.getSanityEnvVars({env: 'production', basePath: workDir})
github sanity-io / sanity / packages / @sanity / core / src / actions / start / startAction.js View on Github external
export default async (args, context) => {
  const flags = args.extOptions
  const {output, workDir} = context

  await ensureProjectConfig(context)

  const sanityConfig = getConfig(workDir)
  const config = sanityConfig.get('server')
  const {port, hostname} = config
  const httpHost = flags.host === 'all' ? '0.0.0.0' : flags.host || hostname
  const httpPort = flags.port || port

  const serverOptions = {
    staticPath: resolveStaticPath(workDir, config),
    basePath: workDir,
    httpHost,
    httpPort,
    context,
    project: sanityConfig.get('project')
  }

  checkStudioDependencyVersions(workDir)