Structured Content 2022: Join our conference to explore fresh perspectives on content and digital experiences →

Source vs. compiled paths

What just happened? The CLI command sanity check is running in production mode, and got this error.

The reason may be that you have defined a compiled path in the sanity.json file in your Studio. This tells Sanity to look for the files in a different location when running in production mode.

Another reason may be that sanity check has found a Studio plugin which is published on npm with files that are not compiled.

The paths propery in a sanity.json file tells Sanity where to look for both compiled and uncompiled code files. Given the following sanity.json config:

{
  "paths": {
    "source": "./src",
    "compiled": "./lib"
  },
  "parts": [
    {
      "implements": "part:@sanity/base/tool",
      "path": "my-tool/index.js"
    }
  ]
}

Sanity will look for source files in ./src (relative to the location of the sanity.json file) and compiled files in ./lib. In the particular case above, the tool source should be in ./src/my-tool/index.js and the compiled version will end up in ./lib/my-tool/index.js.

If a plugin doesn't require any Babel compilation, the sanity.json for that plugin doesn't need a declaration of the paths property.

You can read more about sanity.json and parts.

Was this article helpful?