https://tailwindcss.com/ A utility-first CSS framework for rapidly building custom designs.
- Install tailwindcss, postcss-cli, and autoprefixer
npm install tailwindcss post-cli autoprefixer
- Init tailwind configuration files
npx tailwind init
or
npx tailwind init tailwind-full.config.js --full
- Create postcss.config.js file
module.exports = {
plugins: [
require('tailwindcss'),
require('autoprefixer')
]
}
- Create tailwind.css file
@tailwind base;
@tailwind components;
@tailwind utilities;
...
- Create build script in your package.json
"scripts": {
"build": "postcss css/tailwind.css -o public/build/tailwind.css"
},
- Install live-server package to help speed up development (live reload on browser)
npm install -g live-server
- Optimize production build with remove unused css with purgecss.com
npm install @fullhuman/postcss-purgecss
and add in postcss.config.js
process.env.NODE_ENV === 'production' && require('@fullhuman/postcss-purgecss')({
content: [
'./public/index.html'
],
defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || []
})