Turborepo is a high-performance build system for JavaScript and TypeScript codebases. It is designed to be incrementally adopted, so you can add it to most codebases in a few minutes.
Turborepo leverages advanced build system techniques to speed up development, both on your local machine and your CI/CD. It does this by:
Using caching to avoid re-running tasks that have already been run.
Optimizing task pipelines to run as efficiently as possible.
Providing a unified interface for running tasks, regardless of the underlying build tool.
Turborepo can be used to build a wide variety of JavaScript and TypeScript projects, including:
Single-page applications (SPAs)
Serverless functions
Progressive web apps (PWAs)
Command-line tools
To use Turborepo, you first need to install it. You can do this with the following command:
docs
: a Next.js appweb
: another Next.js appui
: a stub React component library shared by both web
and docs
applicationseslint-config-custom
: eslint
configurations (includes eslint-config-next
and eslint-config-prettier
)tsconfig
: tsconfig.json
s used throughout the monorepoEach package/app is 100% TypeScript.
This Turborepo has some additional tools already setup for you:
To build all apps and packages, run the following command:
cd my-turborepo
pnpm build
To develop all apps and packages, run the following command:
cd my-turborepo
pnpm dev
Turborepo can use a technique known as Remote Caching to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines.
By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can create one, then enter the following commands:
cd my-turborepo
npx turbo login
This will authenticate the Turborepo CLI with your Vercel account.
Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo:
npx turbo link
Learn more about the power of Turborepo:
To seed the database we need to run pnpm prisma db seed
command going to the apps/server/
directory
We can also sync our database before seeding with command pnpm prisma db seed
To do it at the first time we have to run pnpm prisma reset
. This will remove everything from our database and run the migrations and seed the db.