npx create-react-app app_name
npm install -D tailwindcss@npm:@tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9
npm install @craco/craco
Rimpiazza nel package.json:
"start": "craco start",
"build": "craco build",
"test": "craco test",
Crea il file di configurazione:
// craco.config.js
module.exports = {
style: {
postcss: {
plugins: [
require('tailwindcss'),
require('autoprefixer'),
],
},
},
}
Crea il file tailwind.config.js
npx tailwindcss-cli@latest init
Ottimizzazioni:
// tailwind.config.js
mode: "jit",
purge: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'],
Includere tailwind:
/* ./src/index.css */
@tailwind base;
@tailwind components;
@tailwind utilities;