Skip to content

Commit bbaabae

Browse files
committed
Add TailwindCSS purging in production
1 parent dab0b52 commit bbaabae

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ This is extraction originally created inside the [tailwindcss-rails](https://git
1212
1. Run `./bin/bundle add tailwindcss-rails-webpacker`
1313
2. Run `./bin/rails tailwindcss:install`
1414

15+
## Purging in production
16+
17+
The Tailwind CSS framework starts out as a massive file, which gives you all the combinations of utility classes for development, but you wouldn't want to ship all those unused classes in production.
18+
19+
This gem will automatically purge those unused classes in production.
1520

1621
## License
1722

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
// Purge unused TailwindCSS styles
3+
purge: {
4+
enabled: ["production"].includes(process.env.NODE_ENV),
5+
content: [
6+
'./**/*.html.erb',
7+
'./app/helpers/**/*.rb',
8+
'./app/javascript/**/*.js',
9+
],
10+
},
11+
darkMode: 'media', // or 'media' or 'class'
12+
theme: {
13+
extend: {},
14+
},
15+
variants: {
16+
extend: {},
17+
},
18+
plugins: [],
19+
}

lib/install/tailwindcss.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
say "Configuring Tailwind CSS"
99
directory Pathname.new(__dir__).join("stylesheets"), Webpacker.config.source_path.join("stylesheets")
10-
Dir.chdir(WEBPACK_STYLESHEETS_PATH) { run "npx tailwindcss init" }
1110

1211
insert_into_file "postcss.config.js", "require('tailwindcss')(\"./app/javascript/stylesheets/tailwind.config.js\"),\n ",
1312
before: "require('postcss-import')"

0 commit comments

Comments
 (0)