This is an official starter Turborepo.
Run the following command:
npx create-turbo@latest
This Turborepo includes the following packages/apps:
web
: Current Web Applicationui
: A component library used byweb
.eslint-config-custom
:eslint
configurations (includeseslint-config-next
andeslint-config-prettier
)jestconfig
:jest
configurationstsconfig
:tsconfig.json
s used throughout the monorepotailwindconfig
:tailwind.config.js
used throughout the monorepo
Each package/app is 100% TypeScript.
This Turborepo has some additional tools already setup for you:
- TypeScript for static type checking
- ESLint for code linting
- Prettier for code formatting
- Jest for testing
- TailwindCSS for styling
- FlowbiteUI for UI components
- Storybook for component development
- Zustand for state management
To build all apps and packages, run the following command:
npm run build
Note: Building the app will also run npm build storybook
To develop all apps and packages, run the following command:
npm run dev
Note: Developing the app will also run npm run storybook
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 <path-to-your-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
This guide outlines the steps to add and configure a new dependency within a TurboRepo monorepo.
npm install <package-name>
If the dependency requires a config file, create a new folder within /packages
following the convention <package-name>config
. For instance, jestconfig
.
Inside the config folder (<package-name>config
), create a package.json
file with the following template:
{
"name": "<package-name>config",
"version": "0.0.0",
"main": "./index.ts",
"license": "MIT"
}
In the same config folder, create an index.ts
file. Add the configuration code in this file, for example, jest.config.js
.
In each workspace where you want to use the config, create a config file (e.g., jest.config.js
) and import the config file from the config package:
module.exports = require("jestconfig");
In the package.json
of each workspace, add necessary scripts, for example:
"scripts": {
"test": "jest"
}
In the /packages/ui/package.json
and /packages/web/package.json
, add the dependency for the config package:
"dependencies": {
"jestconfig": "*"
}
Run the following command in the root of the monorepo:
npm install
For better understanding, refer to specific files within the workspace (e.g., /packages/web
):
package.json
tsconfig.json
next.config.js
eslintrc.js
These files demonstrate how to import the config files into the workspace's config files.
This guide helps integrate a new dependency into a TurboRepo monorepo, providing a streamlined approach to configuring and utilizing dependencies across multiple workspaces. Adjust these steps based on specific project needs and configurations.
Feel free to adjust or expand upon this guide for your project's requirements!
Learn more about the power of Turborepo: