xxxxxxxxxx
First add tailwind and postcss
npm install tailwindcss postcss autoprefixer postcss-cli
Initialize tailwindcss
npx tailwindcss init
Create a "postcss.config.js" and paste the following in it
module.exports = {
plugins: [
require('tailwindcss'),
require('autoprefixer'),
]
}
Create the necessary files
mkdir public
mkdir public/styles
touch public/styles/tailwind.css
touch public/styles/style.css
Paste the following in public/styles/tailwind.css
@tailwind base;
@tailwind components;
@tailwind utilities;
The last thing is to add this to the scripts in package.json
"tailwind:css": "postcss public/styles/tailwind.css -o public/styles/style.css"
//Terminal***********
npm install -D tailwindcss OR all at once with npm install -D tailwindcss autoprefixer
THEN
npx tailwindcss init
//Add the paths to all of your template files in your tailwind.config.js file.***********
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/**/*.{html,js,jsx}"], ....comma separated file types
theme: {
extend: {},
},
plugins: [],
}
//Add the Tailwind directives to your CSS***********
@tailwind base;
@tailwind components;
@tailwind utilities;
//Terminal - Start the Tailwind CLI build process....Per docs...Haven't used myself***********
npx tailwindcss -i ./src/input.css -o ./dist/output.css --watch
//You're ready to use! If you want to use postcss, in Terminal***********
npm install -D postcss-import
//postcss.config.js file
module.exports = {
plugins: {
'postcss-import': {},
tailwindcss: {},
autoprefixer: {},
}
}
Source: https://tailwindcss.com/docs/using-with-preprocessors#using-post-css-as-your-preprocessor