Skip to content

Commit c19d64a

Browse files
salmin89aklinker1
andauthored
Added a monorepo example (turbo) (#15)
Co-authored-by: Aaron <[email protected]>
1 parent 53461a5 commit c19d64a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+15575
-4
lines changed

examples/monorepo-turbo/.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# Dependencies
4+
node_modules
5+
.pnp
6+
.pnp.js
7+
8+
# Local env files
9+
.env
10+
.env.local
11+
.env.development.local
12+
.env.test.local
13+
.env.production.local
14+
15+
# Testing
16+
coverage
17+
18+
# Turbo
19+
.turbo
20+
21+
# Vercel
22+
.vercel
23+
24+
# Build Outputs
25+
.next/
26+
out/
27+
build
28+
dist
29+
30+
31+
# Debug
32+
npm-debug.log*
33+
yarn-debug.log*
34+
yarn-error.log*
35+
36+
# Misc
37+
.DS_Store
38+
*.pem

examples/monorepo-turbo/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
name: Turborepo Monorepo
3+
description: Example setup of a monorepo using Turborepo.
4+
packages:
5+
- react
6+
- react-dom
7+
---
8+
9+
# Turborepo starter
10+
11+
This Turborepo starter is maintained by the Turborepo core team.
12+
13+
## Using this example
14+
15+
Run the following command:
16+
17+
```sh
18+
npx create-turbo@latest
19+
```
20+
21+
## What's inside?
22+
23+
This Turborepo includes the following packages/apps:
24+
25+
### Apps and Packages
26+
27+
- `docs`: a [Next.js](https://nextjs.org/) app
28+
- `web`: another [Next.js](https://nextjs.org/) app
29+
- `@repo/ui`: a stub React component library shared by both `web` and `docs` applications
30+
- `@repo/eslint-config`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`)
31+
- `@repo/typescript-config`: `tsconfig.json`s used throughout the monorepo
32+
33+
Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).
34+
35+
### Utilities
36+
37+
This Turborepo has some additional tools already setup for you:
38+
39+
- [TypeScript](https://www.typescriptlang.org/) for static type checking
40+
- [ESLint](https://eslint.org/) for code linting
41+
- [Prettier](https://prettier.io) for code formatting
42+
43+
### Build
44+
45+
To build all apps and packages, run the following command:
46+
47+
```
48+
cd my-turborepo
49+
pnpm build
50+
```
51+
52+
### Develop
53+
54+
To develop all apps and packages, run the following command:
55+
56+
```
57+
cd my-turborepo
58+
pnpm dev
59+
```
60+
61+
### Remote Caching
62+
63+
> [!TIP]
64+
> Vercel Remote Cache is free for all plans. Get started today at [vercel.com](https://vercel.com/signup?/signup?utm_source=remote-cache-sdk&utm_campaign=free_remote_cache).
65+
66+
Turborepo can use a technique known as [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines.
67+
68+
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](https://vercel.com/signup?utm_source=turborepo-examples), then enter the following commands:
69+
70+
```
71+
cd my-turborepo
72+
npx turbo login
73+
```
74+
75+
This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview).
76+
77+
Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo:
78+
79+
```
80+
npx turbo link
81+
```
82+
83+
## Useful Links
84+
85+
Learn more about the power of Turborepo:
86+
87+
- [Tasks](https://turbo.build/repo/docs/core-concepts/monorepos/running-tasks)
88+
- [Caching](https://turbo.build/repo/docs/core-concepts/caching)
89+
- [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching)
90+
- [Filtering](https://turbo.build/repo/docs/core-concepts/monorepos/filtering)
91+
- [Configuration Options](https://turbo.build/repo/docs/reference/configuration)
92+
- [CLI Usage](https://turbo.build/repo/docs/reference/command-line-reference)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
.output
12+
stats.html
13+
stats-*.json
14+
.wxt
15+
web-ext.config.ts
16+
17+
# Editor directories and files
18+
.vscode/*
19+
!.vscode/extensions.json
20+
.idea
21+
.DS_Store
22+
*.suo
23+
*.ntvs*
24+
*.njsproj
25+
*.sln
26+
*.sw?
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# WXT + React
2+
3+
This template should help get you started developing with React in WXT.
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default defineBackground(() => {
2+
console.log('Hello background!', { id: browser.runtime.id });
3+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default defineContentScript({
2+
matches: ['*://*.google.com/*'],
3+
main() {
4+
console.log('Hello content.');
5+
},
6+
});
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#root {
2+
max-width: 1280px;
3+
margin: 0 auto;
4+
padding: 2rem;
5+
text-align: center;
6+
}
7+
8+
.logo {
9+
height: 6em;
10+
padding: 1.5em;
11+
will-change: filter;
12+
transition: filter 300ms;
13+
}
14+
.logo:hover {
15+
filter: drop-shadow(0 0 2em #54bc4ae0);
16+
}
17+
.logo.react:hover {
18+
filter: drop-shadow(0 0 2em #61dafbaa);
19+
}
20+
21+
@keyframes logo-spin {
22+
from {
23+
transform: rotate(0deg);
24+
}
25+
to {
26+
transform: rotate(360deg);
27+
}
28+
}
29+
30+
@media (prefers-reduced-motion: no-preference) {
31+
a:nth-of-type(2) .logo {
32+
animation: logo-spin infinite 20s linear;
33+
}
34+
}
35+
36+
.card {
37+
padding: 2em;
38+
}
39+
40+
.read-the-docs {
41+
color: #888;
42+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Demo from "@repo/ui/demo";
2+
import './App.css';
3+
4+
function App() {
5+
6+
return (
7+
<Demo />
8+
);
9+
}
10+
11+
export default App;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Default Popup Title</title>
7+
<meta name="manifest.type" content="browser_action" />
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="./main.tsx"></script>
12+
</body>
13+
</html>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom/client';
3+
import App from './App.tsx';
4+
import './style.css';
5+
6+
ReactDOM.createRoot(document.getElementById('root')!).render(
7+
<React.StrictMode>
8+
<App />
9+
</React.StrictMode>,
10+
);
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
:root {
2+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3+
line-height: 1.5;
4+
font-weight: 400;
5+
6+
color-scheme: light dark;
7+
color: rgba(255, 255, 255, 0.87);
8+
background-color: #242424;
9+
10+
font-synthesis: none;
11+
text-rendering: optimizeLegibility;
12+
-webkit-font-smoothing: antialiased;
13+
-moz-osx-font-smoothing: grayscale;
14+
-webkit-text-size-adjust: 100%;
15+
}
16+
17+
a {
18+
font-weight: 500;
19+
color: #646cff;
20+
text-decoration: inherit;
21+
}
22+
a:hover {
23+
color: #535bf2;
24+
}
25+
26+
body {
27+
margin: 0;
28+
display: flex;
29+
place-items: center;
30+
min-width: 320px;
31+
min-height: 100vh;
32+
}
33+
34+
h1 {
35+
font-size: 3.2em;
36+
line-height: 1.1;
37+
}
38+
39+
button {
40+
border-radius: 8px;
41+
border: 1px solid transparent;
42+
padding: 0.6em 1.2em;
43+
font-size: 1em;
44+
font-weight: 500;
45+
font-family: inherit;
46+
background-color: #1a1a1a;
47+
cursor: pointer;
48+
transition: border-color 0.25s;
49+
}
50+
button:hover {
51+
border-color: #646cff;
52+
}
53+
button:focus,
54+
button:focus-visible {
55+
outline: 4px auto -webkit-focus-ring-color;
56+
}
57+
58+
@media (prefers-color-scheme: light) {
59+
:root {
60+
color: #213547;
61+
background-color: #ffffff;
62+
}
63+
a:hover {
64+
color: #747bff;
65+
}
66+
button {
67+
background-color: #f9f9f9;
68+
}
69+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "wxt-react-starter",
3+
"description": "manifest.json description",
4+
"private": true,
5+
"version": "0.0.0",
6+
"type": "module",
7+
"scripts": {
8+
"dev": "wxt",
9+
"dev:firefox": "wxt -b firefox",
10+
"build": "wxt build",
11+
"build:firefox": "wxt build -b firefox",
12+
"zip": "wxt zip",
13+
"zip:firefox": "wxt zip -b firefox",
14+
"compile": "tsc --noEmit",
15+
"postinstall": "wxt prepare"
16+
},
17+
"dependencies": {
18+
"react": "^19.0.0",
19+
"react-dom": "^19.0.0",
20+
"@repo/ui": "*"
21+
},
22+
"devDependencies": {
23+
"@types/chrome": "^0.0.280",
24+
"@types/react": "^19.0.1",
25+
"@types/react-dom": "^19.0.2",
26+
"@wxt-dev/module-react": "^1.1.2",
27+
"typescript": "^5.6.3",
28+
"wxt": "^0.19.13"
29+
}
30+
}
Loading
559 Bytes
Loading
916 Bytes
Loading
Loading
Loading
Lines changed: 15 additions & 0 deletions
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./.wxt/tsconfig.json",
3+
"compilerOptions": {
4+
"allowImportingTsExtensions": true,
5+
"jsx": "react-jsx"
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from 'wxt';
2+
3+
// See https://wxt.dev/api/config.html
4+
export default defineConfig({
5+
extensionApi: 'chrome',
6+
modules: ['@wxt-dev/module-react'],
7+
});

0 commit comments

Comments
 (0)