SurfSense/apps/docs/documentation/configuration/turbo.mdx
2024-07-30 16:00:11 -07:00

53 lines
No EOL
1.9 KiB
Text

---
title: Turbo config
"og:title": "Configuring Turbo for FastAPI, Next.js and Turborepo"
description: Configuring Turbo for FastAPI, Next.js and Turborepo.
---
## Introduction
This project was first created using the `create-turbo` npm package:
<CodeGroup>
```bash npm
npx create-turbo@latest
```
```bash yarn
yarn dlx create-turbo@latest
```
```bash pnpm
pnpm dlx create-turbo@latest
```
</CodeGroup>
<Note>It is recommended that you read through the [official documentation](https://turbo.build/repo/docs/getting-started/create-new) to understand the breakdown of the monorepo.</Note>
## Changes to the official Turbo starter
The official Turbo starter is a great starting point for a monorepo, but it has some configurations I did not need. As I will not be sharing code between the backend and frontend (nor the docs), I have **removed** the `packages/ui` directory.
If you want to **add a new package** to the project, please reference the [official documentation](https://turbo.build/repo/docs/handbook/sharing-code/internal-packages).
For quick reference:
1. Create a new folder in `packages/<folder>`
2. Add a `package.json`, with `name` and `types` pointing at `src/index.ts[x]`
3. Add `src/index.ts[x]`, with at least one named export
4. Install your packages from `root`
## Turbo.json
The currently configured `turbo.json` does not have many changes from the official starter. The only change is the addition of the `globalEnv` key.
```json
{
"globalEnv": [
"NODE_ENV"
],
}
```
Without adding these environment variables to the `globalEnv`, you will receive an eslint error when referencing variables in your `.env`, however, your code will still work.
<Warning>
There are different ways that people solve this. While it's possible to use\
`"globalDependencies": ["**/.env"]`, that did not work in this project.\
</Warning>