Skip to content

Commit 4bf0a29

Browse files
committed
Update to make it work with react v18/tailwindcss v3
1 parent 9c18c66 commit 4bf0a29

File tree

2 files changed

+19
-47
lines changed

2 files changed

+19
-47
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
## Create React App - TailwindCSS Starter Generator
22
A simple shell script that uses create-react-app to create a React Project and configures tailwindcss on top of it.
3-
43
### Usage
54
Clone the repo, or copy the run.sh script and then run with bash or any other shell:
65
```bash
7-
bash run.sh name_of_your_project
6+
bash run.sh name_of_your_project
87
```
9-
108
### LICENSE
119
MIT

run.sh

Lines changed: 18 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,35 @@
1-
if ! command -v jq
2-
then
3-
echo "jq is required to be installed for this script"
4-
exit
5-
fi
6-
71
if ! command -v npx
82
then
93
echo "npx is required to be installed for this script"
104
exit
115
fi
126

13-
if ! command -v yarn
14-
then
15-
echo "yarn is required to be installed for this script"
16-
exit
17-
fi
18-
19-
echo "HERE"
7+
echo "Creating a new project using create-react-app"
208
npx create-react-app $1
219
cd $1
22-
yarn add tailwindcss --dev
23-
npx tailwind init tailwind.js --full
24-
yarn add postcss-cli autoprefixer --dev
2510

26-
cat <<EOT >> postcss.config.js
27-
const tailwindcss = require('tailwindcss');
11+
echo "Adding tailwindcss, postcss and autoprefixer as a dependency"
12+
npm add -D tailwindcss postcss autoprefixer
13+
npx tailwindcss init -p
14+
15+
echo "Configuring valid files glob for tailwindcss.config.js"
16+
cat <<EOT > tailwind.config.js
2817
module.exports = {
29-
plugins: [
30-
tailwindcss('./tailwind.js'),
31-
require('autoprefixer'),
32-
],
33-
};
18+
content: [
19+
"./src/**/*.{js,jsx,ts,tsx}",
20+
],
21+
theme: {
22+
extend: {},
23+
},
24+
plugins: [],
25+
}
3426
EOT
3527

36-
mkdir src/styles
37-
38-
cat <<EOT > src/styles/index.css
28+
echo "Configuring src/index.css"
29+
cat <<EOT > src/index.css
3930
@tailwind base;
4031
@tailwind components;
4132
@tailwind utilities;
4233
EOT
4334

44-
touch src/styles/tailwind.css
45-
46-
47-
jq '.scripts={
48-
"build:style":"tailwind build src/styles/index.css -o src/styles/tailwind.css",
49-
"watch:style": "tailwind build src/styles/index.css -o src/styles/tailwind.css --watch",
50-
"start": "npm run build:style && react-scripts start",
51-
"build": "react-scripts build",
52-
"test": "react-scripts test",
53-
"eject": "react-scripts eject"
54-
}' package.json > package.json.temp
55-
mv package.json.temp package.json
56-
57-
rm -rf src/index.css
58-
rm -rf src/App.css
59-
60-
sed -i 's/\.\/index.css/.\/styles\/tailwind.css/' src/index.js
61-
sed -i '/App.css/d' src/App.js
35+
sed -i '' 's|<code>|<code className="border-2 border-indigo-500 bg-indigo-900 rounded-xl p-2">|' src/App.js

0 commit comments

Comments
 (0)