From 057e2cb0160d6614251723bce6ddccd973b93a0c Mon Sep 17 00:00:00 2001 From: Sudhir Jonathan Date: Mon, 18 Jan 2021 17:51:24 +0530 Subject: [PATCH 1/2] Register dependencies with Sprockets to enable cache invalidation --- lib/tailwindcss/compressor.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/tailwindcss/compressor.rb b/lib/tailwindcss/compressor.rb index 92222ecf..48db6af1 100644 --- a/lib/tailwindcss/compressor.rb +++ b/lib/tailwindcss/compressor.rb @@ -14,6 +14,9 @@ def initialize(options = {}) end def call(input) - { data: Tailwindcss::Purger.purge(input[:data], keeping_class_names_from_files: @options[:files_with_class_names]) } + { + data: Tailwindcss::Purger.purge(input[:data], keeping_class_names_from_files: @options[:files_with_class_names]), + dependencies: @options[:files_with_class_names].map { |f| "file-digest://#{f.to_path}" }.to_set + } end end From d02ba17f8e8a973859977825a3cf609dbb4e9ea6 Mon Sep 17 00:00:00 2001 From: Sudhir Jonathan Date: Mon, 18 Jan 2021 18:14:40 +0530 Subject: [PATCH 2/2] Add notes about re-compiling and caching --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c615c7b3..37f54a90 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ This gem just gives access to the standard Tailwind CSS framework. If you need t The last option adds the purger compressor to `config/environments/production.rb`. This ensures that when `assets:precompile` is called during deployment that the unused class names are not included in the tailwind output css used by the app. It also adds a `stylesheet_link_tag "tailwind"` to your `app/views/application.html.erb` file. +However, re-compiling assets does not currently work as expected because of caching in Sprockets, so you'll need to call `assets:clobber` and `assets:precompile` on each deployment for now. + You can do both things yourself, if you've changed the default setup. If you need to customize what files are searched for class names, you need to replace the compressor line with something like: