Skip to content

Commit

Permalink
docs: add monorepo example (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyarthan authored Mar 12, 2024
1 parent 97f14de commit 8668d68
Show file tree
Hide file tree
Showing 35 changed files with 2,946 additions and 43 deletions.
6 changes: 6 additions & 0 deletions docs/guide/monorepo.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ const config = {

export default config;
```

::: tip

For a full example see [examples/monorepo](https://github.com/titanom/css2tailwind/tree/master/examples/monorepo).

:::
24 changes: 24 additions & 0 deletions examples/monorepo/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
30 changes: 30 additions & 0 deletions examples/monorepo/app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
}
```

- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
13 changes: 13 additions & 0 deletions examples/monorepo/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions examples/monorepo/app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@repo/app",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"format": "prettier --write .",
"format:check": "prettier --check ."
},
"dependencies": {
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@repo/ui": "workspace:^",
"@types/react": "18.2.64",
"@types/react-dom": "18.2.21",
"@vitejs/plugin-react-swc": "3.5.0",
"autoprefixer": "10.4.18",
"postcss": "8.4.35",
"tailwindcss": "3.4.1",
"typescript": "5.2.2",
"vite": "5.1.6"
}
}
6 changes: 6 additions & 0 deletions examples/monorepo/app/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
1 change: 1 addition & 0 deletions examples/monorepo/app/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions examples/monorepo/app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function App() {
return (
<div>
<button className="button button-primary">Button</button>
</div>
);
}
3 changes: 3 additions & 0 deletions examples/monorepo/app/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
12 changes: 12 additions & 0 deletions examples/monorepo/app/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import ReactDOM from 'react-dom/client';

import App from './App.tsx';

import './index.css';

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
);
1 change: 1 addition & 0 deletions examples/monorepo/app/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
10 changes: 10 additions & 0 deletions examples/monorepo/app/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { plugin } from '../ui/tailwind.config';

import type { Config } from 'tailwindcss';

const config = {
content: ['./src/index.html', './src/**/*.tsx'],
plugins: [plugin],
} satisfies Config;

export default config;
25 changes: 25 additions & 0 deletions examples/monorepo/app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
11 changes: 11 additions & 0 deletions examples/monorepo/app/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"strict": true
},
"include": ["vite.config.ts"]
}
7 changes: 7 additions & 0 deletions examples/monorepo/app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import react from '@vitejs/plugin-react-swc';
import { defineConfig } from 'vite';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
});
16 changes: 16 additions & 0 deletions examples/monorepo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "repo",
"scripts": {
"dev": "turbo dev",
"build": "turbo build",
"preview": "turbo preview",
"format": "turbo root:format format",
"format:check": "turbo root:format:check format:check",
"root:format": "prettier --write ./*.*",
"root:format:check": "prettier --check ./*.*"
},
"devDependencies": {
"turbo": "^1.12.5"
}
}
Loading

0 comments on commit 8668d68

Please sign in to comment.