Last active
April 7, 2022 06:10
-
-
Save anuran-roy/2d4018684340afaaa613c01a6d438210 to your computer and use it in GitHub Desktop.
Spawn a React App quickly using Typescript template and Tailwind CSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# Usage: ./cra-tailwind-ts.sh <APP_NAME> <DIRECTORY (Optional)> | |
# Example: ./cra-tailwind-ts.sh hi => This will create a react app with typescript template and Tailwind CSS in the current working directory | |
# Example: ./cra-tailwind-ts.sh hi playground/=> This will create a react app with typescript template and Tailwind CSS on the playground/ directory | |
nvm use --lts; | |
APP_NAME=$1; | |
LOC=$2; | |
if [ $# -eq 2 ] | |
then | |
if [ -d $LOC ] | |
then | |
cd $LOC; | |
else | |
mkdir $LOC; | |
cd $LOC; | |
fi | |
fi | |
npx create-react-app $APP_NAME --template typescript; | |
echo "Successfully created React app $APP_NAME with typescript template on directory ${pwd}"; | |
cd $APP_NAME; | |
echo "\nInstalling Tailwind CSS:\n"; | |
npm install -D tailwindcss postcss autoprefixer react-scripts@latest; | |
echo "\nInstalling Prettier:\n"; | |
npm install --save-dev --save-exact prettier prettier-plugin-tailwindcss; | |
echo "\nConfiguring Prettier:\n"; | |
echo {}> .prettierrc.json | |
echo "build\ncoverage\n" > .prettierignore | |
cd src; | |
npx prettier --write .; | |
echo '@tailwind base;\n@tailwind components;\n@tailwind utilities;\n' | cat - index.css > temp && mv temp index.css; | |
npx tailwindcss init -p; | |
CONTENT='module.exports = {content: [\n "./src/**/*.{js,jsx,ts,tsx}",\n ],\n theme: {\n extend: {},\n },\n plugins: [],\n}\n'; | |
echo $CONTENT >> tailwind.config.js; | |
cd ../../ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment