TracksMastering Content OperationsCoursesDay One Content OperationsPrepare your monorepo
Day One Content Operations
Markdown Version

Prepare your monorepo

Log in to watch a video walkthrough of this lesson
Log in
Video thumbnail
Setup a PNPM workspace to more efficiently move through the rest of this course while developing multiple applications.
Log in to mark your progress for each Lesson and Task

Sanity is much more than a CMS, and Sanity Studio is just one part of the Content Operating System. Before creating more Sanity-driven applications, let's configure your project files in a way that will better suit the rest of the course material.

Putting multiple applications into a "monorepo" is a popular way of colocating separate-but-related applications.

Configuring a PNPM workspace is a popular standard for monorepos and allows you to install dependencies or start development servers across a number of applications with a single command.

The following files are the minimum you need to create a PNPM workspace.

Create a package.json file at the root of the project
{
"name": "day-one-content-operations",
"private": true,
"version": "1.0.0",
"description": "Day One Content Operations",
"scripts": {
"dev": "pnpm run --parallel dev",
"build": "pnpm run --parallel build"
},
"engines": {
"node": ">=20.0.0",
"pnpm": ">=10.0.0"
}
}
Create a pnpm-workspace.yaml file at the root of the project
packages:
- "apps/*"
Create a README.md file at the root of the project
# Day One Content Operations
Applications developed while following lessons on sanity.io/learn
Create a .gitignore file at the root of the project
node_modules

You can now run the following command from the root (day-one) directory to install dependencies across multiple applications:

# in the root directory
pnpm install

Or run the following to concurrently run the development servers for all your applications:

# in the root directory
pnpm run dev

You only have one application now, but you will create a second one in the next lesson.

While this course will not teach you how to use git, it is expected that you would check this project into a repository and push changes as you work through stages.

If you're entirely new to Git, Epic Web has a free Git Fundamentals tutorial, which will get you up to speed with the basics.

When the Sanity CLI created the apps/studio directory it had git already initialized. But you'll want to version control all files in this monorepo from the root.

Without the following steps the apps/studio directory would be a "git submodule" and this is a world of complexity and pain for which neither you or I have the appetite for.

Run the following command to remove the .git directory from the apps/studio directory
# from the "day-one" directory
rm -rf apps/studio/.git
Run the following command to initialize git at the root
git init

You should now link your local directory to a remote repository using the provider (GitHub, BitBucket, etc) of your choice.

In the following lessons this course assumes you'll also be a good developer citizen and work in branches, not just force-push all your work to main.

The foundation is set, let's add our second app to this monorepo in the following lesson.

You have 6 uncompleted tasks in this lesson
0 of 6