3

Working with a Version 3 Sanity project to provide backend data.

However, I noticed that there are two files that deals with project settings/configurations.

  1. PROJECT_DIR/sanity.config.js - included from startup
  2. PROJECT_DIR/sanity.json - not included from startup

My question are

  1. What is the difference between the two
  2. How should I handle duplicate settings such as plugins that are already defined in sanity.config.js, do I define them again in sanity.json?

Please help, as I cannot find any documentation that addresses my questions above,

An example taken from sanity docs sanity.json

{
  "root": true,
  "project": {
    "name": "Movies",
    "basePath": "/studio"
  },
  "api": {
    "projectId": "<yourProjectID>",
    "dataset": "production"
  },
  "plugins": [
    "@sanity/base",
    "@sanity/components",
    "@sanity/default-layout",
    "@sanity/default-login",
    "@sanity/desk-tool",
    "@sanity/google-maps-input"
  ],
  "parts": [
    {
      "name": "part:@sanity/base/schema",
      "path": "./schemas/schema.js"
    }
  ]
}

And an example from my project sanity.config.js

import {defineConfig} from 'sanity'
import {deskTool} from 'sanity/desk'
import {visionTool} from '@sanity/vision'
import {schemaTypes} from './schemas'

export default defineConfig({
  name: 'default',
  title: 'app-title',

  projectId: '<project-id>',
  dataset: 'production',

  plugins: [deskTool(), visionTool()],

  schema: {
    types: schemaTypes,
  },
})

Would I still include "@sanity/desk-tool" in my sanity.json if deskTool() is already added within the plugins array in sanity.config.js

1 Answer 1

3

The JSON-based configuration in sanity.json file has been deprecated on Sanity v3 in favor of sanity.config.js file, this is one of their breaking changes. See docs for reference. In other words, if you're using Sanity v3, don't include sanity.json, handle all the configs that were previously in that file on sanity.config.js.

1
  • Oh wow, totally missed it. I feel like the documentation on https://www.sanity.io/docs/sanity-json could have done a better job of informing users that sanity.json is deprecated in v3. Thank you for pointing that out!
    – 0x5929
    Jan 12, 2023 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.