Skip to content

Commit aa22971

Browse files
Add v3 playground
1 parent acc006e commit aa22971

File tree

12 files changed

+1052
-50
lines changed

12 files changed

+1052
-50
lines changed

playgrounds/v3/.eslintrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "next/core-web-vitals",
3+
"rules": {
4+
"react/no-unescaped-entities": "off",
5+
"react/jsx-no-comment-textnodes": "off"
6+
}
7+
}

playgrounds/v3/.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
.yarn/install-state.gz
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts

playgrounds/v3/app/globals.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import 'tailwindcss/base';
2+
@import 'tailwindcss/components';
3+
@import 'tailwindcss/utilities';

playgrounds/v3/app/layout.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type { Metadata } from 'next'
2+
import { Inter } from 'next/font/google'
3+
import './globals.css'
4+
5+
const inter = Inter({ subsets: ['latin'] })
6+
7+
export const metadata: Metadata = {
8+
title: 'Create Next App',
9+
description: 'Generated by create next app',
10+
}
11+
12+
export default function RootLayout({
13+
children,
14+
}: Readonly<{
15+
children: React.ReactNode
16+
}>) {
17+
return (
18+
<html lang="en" className="[&_h1]:font-thin">
19+
<head>{/* <script src="https://cdn.tailwindcss.com"></script> */}</head>
20+
<body className={inter.className}>{children}</body>
21+
</html>
22+
)
23+
}

playgrounds/v3/app/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Home() {
2+
return <h1 className="text-3xl font-bold underline border ring">Hello world!</h1>
3+
}

playgrounds/v3/next.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** @type {import('next').NextConfig} */
2+
const nextConfig = {}
3+
4+
export default nextConfig

playgrounds/v3/package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "v3-playground",
3+
"private": true,
4+
"scripts": {
5+
"dev": "next dev",
6+
"build": "next build",
7+
"start": "next start",
8+
"lint": "next lint",
9+
"upgrade": "node scripts/upgrade.mjs"
10+
},
11+
"dependencies": {
12+
"next": "14.1.0",
13+
"react": "^18.3.1",
14+
"react-dom": "^18.3.1",
15+
"tailwindcss": "^3"
16+
},
17+
"devDependencies": {
18+
"@types/node": "^20.14.8",
19+
"@types/react": "^18.3.9",
20+
"@types/react-dom": "^18.3.1",
21+
"autoprefixer": "^10.4.20",
22+
"eslint": "^9.11.1",
23+
"eslint-config-next": "^14.2.5",
24+
"typescript": "^5.5.4"
25+
}
26+
}

playgrounds/v3/postcss.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
}

playgrounds/v3/scripts/upgrade.mjs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { execSync } from 'node:child_process'
2+
import fs from 'node:fs/promises'
3+
import path from 'node:path'
4+
import { fileURLToPath } from 'node:url'
5+
6+
const __dirname = fileURLToPath(new URL('.', import.meta.url))
7+
const cwd = path.join(__dirname, '..')
8+
9+
let originalLockfile = await fs.readFile(path.join(cwd, '../../pnpm-lock.yaml'), 'utf-8')
10+
11+
console.log('Overwriting dependencies for @tailwindcss/upgrade')
12+
13+
// Apply package patches
14+
let json = JSON.parse(await fs.readFile('package.json', 'utf-8'))
15+
json.pnpm = {
16+
overrides: {
17+
'@tailwindcss/upgrade>tailwindcss': 'file:../../dist/tailwindcss.tgz',
18+
'@tailwindcss/upgrade>@tailwindcss/node': 'file:../../dist/tailwindcss-node.tgz',
19+
},
20+
}
21+
json.devDependencies['@tailwindcss/upgrade'] = 'file:../../dist/tailwindcss-upgrade.tgz'
22+
await fs.writeFile('package.json', JSON.stringify(json, null, 2))
23+
24+
try {
25+
execSync('pnpm install --ignore-workspace', { cwd })
26+
} catch (error) {
27+
console.error(error.stdout?.toString() ?? error)
28+
}
29+
30+
execSync('npx @tailwindcss/upgrade --force', { cwd, stdio: 'inherit' })
31+
32+
// Undo package patches
33+
json = JSON.parse(await fs.readFile('package.json', 'utf-8'))
34+
delete json.pnpm
35+
delete json.devDependencies['@tailwindcss/upgrade']
36+
await fs.writeFile('package.json', JSON.stringify(json, null, 2))
37+
38+
// Restore original lockfile (to avoid unnecessary changes in git diff)
39+
await fs.writeFile(path.join(cwd, '../../pnpm-lock.yaml'), originalLockfile)
40+
await fs.unlink(path.join(cwd, 'pnpm-lock.yaml'))

playgrounds/v3/tailwind.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** @type {import('tailwindcss').Config} */
2+
module.exports = {
3+
content: ['./app/**/*.tsx'],
4+
}

0 commit comments

Comments
 (0)