pickstack

Astro + Turborepo

Monorepo: the app in apps/web, tasks cached by turbo. This page shows exactly what pickstack adds to a Astro project for Turborepo: the packages, the new files and the changes to existing ones. Every combination is installed, built, linted and tested in CI.

$ npm create pickstack@latest my-app -- --framework astro --modules turborepo --yes
Customize in the configurator

Packages it adds

PackageVersionType
turbo^2.11.13dev

New files

apps/web/.gitignore
node_modules
dist
.astro
.env
.env.local
.DS_Store
apps/web/astro.config.mjs
// @ts-check
import { defineConfig } from "astro/config";

// https://astro.build/config
export default defineConfig({});
apps/web/package.json
{
  "name": "web",
  "private": true,
  "version": "0.1.0",
  "type": "module",
  "scripts": {
    "dev": "astro dev",
    "build": "astro build",
    "preview": "astro preview",
    "astro": "astro",
    "typecheck": "astro check"
  },
  "dependencies": {
    "astro": "^7.4.13"
  },
  "devDependencies": {
    "@astrojs/check": "^0.9.12",
    "typescript": "~6.0.3"
  }
}
apps/web/src/components/Counter.astro
<counter-card>
  <div class="card">
    <p class="count" data-count>
      0
    </p>
    <div class="row">
      <button type="button" class="btn" data-step="-1">
        -1
      </button>
      <button type="button" class="btn" data-step="1">
        +1
      </button>
    </div>
  </div>
</counter-card>

<script>
  class CounterCard extends HTMLElement {
    connectedCallback() {
      const output = this.querySelector("[data-count]");
      let count = 0;
      for (const button of this.querySelectorAll("button")) {
        button.addEventListener("click", () => {
          count += Number(button.dataset.step);
          if (output) output.textContent = String(count);
        });
      }
    }
  }

  customElements.define("counter-card", CounterCard);
</script>
apps/web/src/layouts/Layout.astro
---
import "../styles/global.css";

interface Props {
  title: string;
}

const { title } = Astro.props;
---

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <meta name="generator" content={Astro.generator} />
    <title>{title}</title>
  </head>
  <body>
    <main class="app">
      <nav class="nav">
        <a class="link" href="/">
          Home
        </a>
        <a class="link" href="/about">
          About
        </a>
      </nav>
      <slot />
    </main>
  </body>
</html>
apps/web/src/pages/about.astro
---
import Layout from "../layouts/Layout.astro";
---

<Layout title="About">
  <section class="page">
    <h1 class="title">About</h1>
    <p class="text">Built with Astro, TypeScript, Turborepo.</p>
  </section>
</Layout>
apps/web/src/pages/index.astro
---
import Counter from "../components/Counter.astro";
import Layout from "../layouts/Layout.astro";
---

<Layout title="Home">
  <section class="page">
    <h1 class="title">my-app</h1>
    <Counter />
  </section>
</Layout>
apps/web/src/styles/global.css
:root {
  font-family: system-ui, sans-serif;
  color: #0f172a;
  background: #f8fafc;
}

body {
  margin: 0;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 2rem;
  box-sizing: border-box;
}

.title {
  font-size: 1.875rem;
  margin: 0;
}

.nav {
  display: flex;
  gap: 1rem;
}

.link {
  color: #475569;
  text-decoration: none;
  font-weight: 500;
}

.link:hover {
  color: #0f172a;
}

.page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.text {
  max-width: 28rem;
  text-align: center;
  color: #475569;
}

.card {
  background: #fff;
  padding: 2rem;
  border-radius: 1rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  text-align: center;
}

.count {
  font-size: 3rem;
  font-weight: 700;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.row {
  margin-top: 1.5rem;
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.btn {
  background: #0f172a;
  color: #fff;
  border: 0;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font: inherit;
  cursor: pointer;
}

.btn:hover {
  background: #334155;
}
apps/web/tsconfig.json
{
  "extends": "astro/tsconfigs/strict",
  "include": [".astro/types.d.ts", "**/*"],
  "exclude": ["dist"]
}
turbo.json
{
  "$schema": "https://turborepo.dev/schema.json",
  "ui": "tui",
  "tasks": {
    "build": {
      "dependsOn": ["^build"],
      "inputs": ["$TURBO_DEFAULT$", ".env*"],
      "outputs": ["dist/**"]
    },
    "dev": {
      "cache": false,
      "persistent": true
    },
    "typecheck": {
      "dependsOn": ["^typecheck"]
    }
  }
}

Changes to existing files

.gitignore (changed)
 node_modules+.turbo−dist−.astro .env .env.local .DS_Store⋯ 1 unchanged lines

Project files

Related templates