Skip to content

Instantly share code, notes, and snippets.

@iberno
Last active January 31, 2020 11:52
Show Gist options
  • Save iberno/aa0dc7a13d0c3acebd8568a86fce3f05 to your computer and use it in GitHub Desktop.
Save iberno/aa0dc7a13d0c3acebd8568a86fce3f05 to your computer and use it in GitHub Desktop.
Install Tailwindcss on Reactjs
# Installations
npm install --save-dev or yarn add tailwindcss -D
npm install --save-dev or yarn add ṕostcss autoprefixer -D
#Config File
Generate tailwind file using npx tailwind int tailwind.js
create postfix.config.js on your folder project
#copy and past to postfix config file
const tailwindcss = require('tailwindcss');
module.exports = {
plugins: [
tailwindcss('./tailwind.js'),
require('autoprefixer'),
],
};
#create a tailwindcss.css, copy and past to
@tailwind base;
@tailwind components;
@tailwind utilities;
#on you packaje.js include this 2 lines on scripts
"build:css":"tailwind build src/tailwind.css -o src/styles/index.css",
"watch:css":"tailwind build src/tailwind.css -o src/styles/index.css -w",
#update you start and build scripts to
"start": "npm run watch:css && react-scripts start",
"build": "npm run watch:css && react-scripts build",
#create a folder called styles and index.css inside
#on your first (project file) index.js file includes
import './styles/index.css'
run yarn or npm start and try to use the tailwind class on your project
Done!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment