Turborepo
A monorepo is a single repository containing multiple distinct projects, with well-defined relationships. learn more at monorepo.tools
Turborepoenable managing deployable apps and associated Sharing Code in single git repo. Sharing Code cab be either Internal Packages or External Packages
Internal packages are packages which are only intended to be used inside your monorepo. They're extremely useful for sharing code between apps in closed-source monorepos. External packages run their files through a bundler before putting them on a package registry.
What's inside?
This Turborepo includes the following packages/apps:
Apps and Packages
WebApps
playground: an experimental svelte-kit web app to play with new ideas.docs: a sample documentation web app build with astro's starlightweb: a sample landing page web app build with astroconsole: a sample dashboard web app build with svelte-kit
Packages
ui: a stub Svelte component library shared by bothwebanddocsapplicationseslint-config:eslintconfigurations (includeseslint-plugin-svelteandeslint-config-prettier)prettier-config: sharedprettierconfigurations (plugins etc...)typescript-config: sharedtsconfigfilesutils: utility functions used throughout the monorepo
Utilities
This Turborepo has some additional tools already setup for you:
TypeScript for static type checking
ESLint for code linting
Prettier for code formatting
Prerequisite
Turbo CLI
pnpm add -g turbo@latestVS Code monorepo plugin: Monorepo Focus Workspace
code --install-extension alberto-varela.monorepo-focus-workspaceSetup
Create sveltekit turborepo
to create a new sveltekit turborepo, Run the following command:
pnpx create-turbo@latest -e with-svelte
# bunx create-turbo@latest -e with-svelteSetup Remote Caching for Turborepo on Vercel
pnpx turbo login
pnpx turbo link
# bunx turbo loginUsage
Environment
App Environment Variables
Turbo is working on first-class solution to load dotEnv files. Meanwhile we recommend using a library called dotenv-run to solve this problem.
turbo automatically include environment variables from .env , .secrets as we set them at globalDotEnv in turbo.json
Run
turbo dev --filter=playground
turbo dev --filter=web
turbo dev --filter=docsTest
turbo test --filter=helpersBuild
turbo build --filter=playground...
turbo build --filter=playground... --summarize
turbo build --filter=playground... --dry
turbo build --filter=playground... --graphMaintenance
migrate command which both upgrades your repo to the specified version (latest by default) of turbo, and runs any codemods required.
pnpx @turbo/codemod migrateDocker Build
# for dockerfile
turbo prune --scope=playground --dockerGuides
turbo build
turbo dev
turbo dev --filter=playground
turbo lint
turbo run generate
pnpx turbo login
turbo prune --scope=playground --dockerLast updated
Was this helpful?