Tailwind css file very big 2.42 mib how can i reduce size this file am using laravel ?
The best strategy is to use generate a specific CSS specific to your need and deploy it on your own CDN
Below an example that explains how to configure TailwindCSS for a simple Html Project
yarn init
yarn add tailwindcss postcss-cli autoprefixer -D
yarn add tailwindcss postcss-cli autoprefixer -D
npx tailwind init tailwind.js -full
touch postcss.config.js
const tailwindcss = require('tailwindcss');
module.exports = {
plugins: [
tailwindcss('./tailwind.js'),
require('autoprefixer')
],
purge: [
'./src/**/*.html',
],
};
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
npx postcss tailwind.css -o style.css
<html>
<head>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<h1>Hello world</h1>
</body>
</html>
(Possible CDN : CloudFront / Netlify)
Edit your tailwind.config.js and set purge.enabled = true:
const tailwindcss = require('tailwindcss');
module.exports = {
purge: {
enabled: true,
content: ['./src/**/*.{vue,js,ts,jsx,tsx}']
},
...
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With