3

I'm getting started with sanity V3 and am using this official sanity starter https://www.sanity.io/templates/personal-website-with-built-in-content-editing

Maybe I'm missing the obvious but there are no instructions on how to deploy the sanity studio? How does one do this

I installed sanity/cli and ran npx sanity deploy but get stuck with this error

Error: [vite]: Rollup failed to resolve import "lib/sanity.api" from "/Users/sashabb/Documents/apps/love-tilly-devine/sanity.config.ts".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`

Any suggestions would be amazing

1 Answer 1

3

The application you're looking at is meant to be deployed on Vercel or another NEXTjs deployment service.

If you want to build and deploy the studio on sanity you have to make sure that those weird non-relative imports like lib/... is resolved when you build the sanity studio.

The sanity studio is built using vite, so you could add a vite plugin called vite-tsconfig-paths

and set up a sanity.cli.ts file like so:

export default defineCliConfig({
  api: { projectId, dataset },
  vite: (viteConfig: UserConfig): UserConfig => ({
    ...viteConfig,
    plugins: [tsConfigPaths(), ...viteConfig.plugins],
    // ...rest of config
  }),
})

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.