Watch Tailwind CSS Crash Course https://youtu.be/mVzY256R9fs
- Create package.json file with default options
npm init –y
- Install Tailwind CSS
npm install tailwindcss
- Install AutoPrefixer
npm install autoprefixer
- Create public Folder then inside public folder create index.html. public/index.html where you can write your html code.
- Create src Folder then inside src folder create tailwind.css file (You can change file name). src/tailwind.css file is used to write tailwind directives and custom CSS.
- Open src/tailwind.css file then write code
@tailwind base; @tailwind components; /* Write Custom CSS */ @tailwind utilities;
- Create Build Script which will compile src/tailwind.css file to actual css file. To do this, Open package.json file then write code
"scripts": {"build": "tailwindcss build ./src/tailwind.css -o ./public/tailwind.css"}
- Run the script
npm run build
This will generate a compiled tailwind.css file inside public folder. This public/tailwind.css file has actual tailwind css code. You should not modify this file.
- Done
Note - If we are working on a small project which doesn’t use any kind of framework then we should use “Tailwind CSS without PostCSS” process to install tailwind.
- Create tailwind configuration file
npx tailwindcss init
This will generate tailwind.config.js file
- tailwind.config.js file is used to configure your own color palette, font, apply, purge etc.
- Whenever you do changes in tailwind.config.js file you need to run
npm run build
- Install NODE_ENV
npm install win-node-env
- Open package.json File then write below script
"scripts": {"prod": "NODE_ENV=production npx tailwindcss build ./src/tailwind.css -o ./public/tailwind.css“},
- Include which file should be purged. Open tailwind.config.js file then write code
purge:[‘./public/**/*.html’]
- Make your code Production Ready
npm run prod
- Create package.json file with default options
npm init –y
- Install Tailwind CSS
npm install tailwindcss
- Install AutoPrefixer
npm install autoprefixer
- Install PostCSS CLI
npm install postcss-cli
- Create Configuration files for Tailwind CSS and PostCSS
npx tailwindcss init -p
This will generate two files tailwind.config.js and postcss.config.js
- Create public Folder then inside public folder create index.html. public/index.html where you can write your html code.
- Create src Folder then inside src folder create tailwind.css file (You can change file name). src/tailwind.css file is used to write tailwind directives and custom CSS.
- Open src/tailwind.css file then write code
@tailwind base; @tailwind components; /* Write Custom CSS */ @tailwind utilities;
- Create Build Script which will compile src/tailwind.css file to actual css file. To do this, Open package.json file then write code
"scripts": {"build": "postcss ./src/tailwind.css -o ./public/tailwind.css"}
- Run the script
npm run build
This will generate a compiled tailwind.css file inside public folder. This public/tailwind.css file has actual tailwind css code. You should not modify this file.
- Done
- tailwind.config.js file is used to configure your own color palette, font, apply, purge etc.
- Whenever you do changes in tailwind.config.js file you need to run
npm run build
- Install NODE_ENV
npm install win-node-env
- Open package.json File then write below script
"scripts": {"prod": "NODE_ENV=production postcss ./src/tailwind.css -o ./public/tailwind.css“},
- Include which file should be purged. Open tailwind.config.js file then write code
purge:[‘./public/**/*.html’]
- Make your code Production Ready
npm run prod