Skip to content

Commit 2097fc4

Browse files
author
David Heinemeier Hansson
committed
Turn off assets cache in production
1 parent a4d72a1 commit 2097fc4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ You can do these things yourself, if you've changed the default setup.
2323

2424
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. So this gem includes a Sprockets compressor that purges the tailwind file from all those unused classes.
2525

26-
This happens automatically on `assets:precompile`, which should always be part of a deployment path, but is not currently compatible with the default sprockets cache. So you must run the `assets:clobber` task prior to `assets:precompile` when deploying to production, or new new usage of additional utility classes from your view and helper files will not be updated.
26+
This compressor is currently not compatible with the default Sprockets cache system due to the fact its output depends on files outside of Sprockets (all the files observed for utility class name usage), so this cache is disabled in production. If you need to disable it in other deployed environments, add the following to that environment configuration file:
27+
28+
```ruby
29+
Rails.application.config.assets.configure do |env|
30+
env.cache = ActiveSupport::Cache.lookup_store(:null_store)
31+
end
32+
```
2733

2834

2935
## Configuration

lib/tailwindcss/engine.rb

+6
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,11 @@ class Engine < ::Rails::Engine
99
initializer "tailwindcss.assets" do
1010
Rails.application.config.assets.precompile += %w( tailwind.css inter-font.css )
1111
end
12+
13+
initializer "tailwindcss.disable_assets_cache" do
14+
Rails.application.config.assets.configure do |env|
15+
env.cache = ActiveSupport::Cache.lookup_store(:null_store)
16+
end if Rails.env.production?
17+
end
1218
end
1319
end

0 commit comments

Comments
 (0)