You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Optimize for production by using Purge CSS and remove unused CSS using the Tailwind configuration file
4
+
description: Optimize your project for production use by setting up Flowbite and Tailwind CSS using our guide
5
5
group: customize
6
6
toc: true
7
7
@@ -11,35 +11,30 @@ next: Accordion
11
11
nextLink: components/accordion/
12
12
---
13
13
14
-
The default development build of FlowBite and Tailwind CSS is roughly 3566.2kB uncompressed, 289.2kB when minified and compressed with Gzip, and 71.3kB when compressed with Brotli.
14
+
The default JavaScript development build of Flowbite and Tailwind CSS is roughly 310kB uncompressed, 136kB when minified via CDN.
15
15
16
-
If you have worked with Tailwind CSS previously, you should already know that you should **use Purge CSS to remove the unused CSS** which was helpful to you when developing.
16
+
Although working with the CDN can be quick and effective, it is not the most efficient way of working with Tailwind CSS and Flowbite. You should definitely check our [quickstart guide](https://flowbite.com/docs/getting-started/quickstart/) and set up Tailwind CSS in your local environment so that the only the CSS being used in your templates will be added to the final CSS file.
17
17
18
18
## Remove unused CSS
19
19
20
-
First of all, you need to set the type of files that you want to be searched for when purging the CSS.
20
+
Since Tailwind v4 you no longer need to set the content paths for your templating files.
21
21
22
-
```javascript
23
-
// tailwind.config.js
24
-
module.exports= {
25
-
content: [
26
-
'./src/**/*.html',
27
-
'./src/**/*.vue',
28
-
'./src/**/*.jsx',
29
-
],
30
-
theme: {},
31
-
plugins: [],
32
-
}
22
+
However, you might want to set custom sources for where the engine should look for utility classes.
23
+
24
+
```css
25
+
@import"tailwindcss";
26
+
27
+
@source "../node_modules/flowbite";
33
28
```
34
29
35
-
The `purge` object should include **all of the files that have classes**, including JavaScript, Markdown, and HTML files.
30
+
## Build for production
36
31
37
-
After that, make sure that you set `NODE_ENV` to `production`.
32
+
When building your CSS, make sure that you set `NODE_ENV` to `production`.
38
33
39
34
The command that you have to run in your terminal for production build would be:
Learn more about how to optimize your code for production by reading the official <ahref="https://tailwindcss.com/docs/optimizing-for-production">Tailwind CSS guide</a>.
40
+
This command will create an `output.css` file that you will include in your templating files.
Copy file name to clipboardExpand all lines: content/getting-started/introduction.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -268,7 +268,7 @@ export default {
268
268
5. Compile the source CSS file using NPX:
269
269
270
270
```bash
271
-
npx @tailwindcss/cli -i main.css -o styles.css
271
+
npx @tailwindcss/cli -i input.css -o output.css
272
272
```
273
273
274
274
Now you should be good to go! Check the <ahref="https://tailwindcss.com/docs/upgrade-guide#changes-from-v3"rel="nofollow"target="_blank">deprecated changes from v3</a> to learn more about the new features.
Copy file name to clipboardExpand all lines: content/getting-started/quickstart.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -193,7 +193,7 @@ export default {
193
193
5. Compile the source CSS file using NPX:
194
194
195
195
```bash
196
-
npx @tailwindcss/cli -i main.css -o styles.css
196
+
npx @tailwindcss/cli -i input.css -o output.css
197
197
```
198
198
199
199
Now you should be good to go! Check the <ahref="https://tailwindcss.com/docs/upgrade-guide#changes-from-v3"rel="nofollow"target="_blank">deprecated changes from v3</a> to learn more about the new features.
0 commit comments