Open ollebergkvist opened 2 years ago
I tried to run the package with the official Vercel example as well, same issue:
https://github.com/vercel/next.js/tree/canary/examples/cms-sanity
Use this line in the config:
schemaPath: './studio/schemas/schema.js',
The script is looking for the file where you run createSchema
, just read the source. This fixed it for me.
I added the path to the schema file as well, which now leads to:
/Users/user/Documents/dev/project/snap-system/apps/cms/schemas/schema.ts:1
import schemaTypes from 'all:part:@sanity/base/schema-type'
^^^^^^
SyntaxError: Cannot use import statement outside a module
@ollebergkvist I think it should be /Users/user/Documents/dev/project/snap-system/apps/cms/schemas/schema
I got it working in my setup. Run npx sanity-codegen in the sanity directory. My utils folder and the babel.config are in the root of the project. ` import { SanityCodegenConfig } from 'sanity-codegen';
const config: SanityCodegenConfig = { schemaPath: './schemas/schema.js', outputPath: '../utils/types/types.ts',
// NOTE: The CLI ships with a pre-configured babel config that shims out
// the Sanity parts system. This babel config does not read from any
// .babelrc
or babel.config.js
. You can only configure extra babel
// options here.
babelOptions: require('../babel.config.js'), // (optional)
};
export default config; `
I'm getting this error running Next, sanity blog example with the codegen.
sanity-codegen.config.ts
Error message:
Dependencies: