1- def run_install_template ( path )
2- system "#{ RbConfig . ruby } ./bin/rails app:template LOCATION=#{ File . expand_path ( "../install/#{ path } .rb" , __dir__ ) } "
3- end
4-
51namespace :tailwindcss do
62 desc "Install Tailwind CSS into the app"
73 task :install do
@@ -12,18 +8,6 @@ namespace :tailwindcss do
128 end
139 end
1410
15- desc "Show the list of class names being kept in Tailwind CSS"
16- task :keeping_class_names do
17- puts Tailwindcss ::Purger . extract_class_names_from ( Rails . root . glob ( "app/views/**/*.*" ) + Rails . root . glob ( "app/helpers/**/*.rb" ) )
18- end
19-
20- desc "Show Tailwind CSS styles that are left after purging unused class names"
21- task :preview_purge do
22- puts Tailwindcss ::Purger . purge \
23- Pathname . new ( __FILE__ ) . join ( "../../../app/assets/stylesheets/tailwind.css" ) . read ,
24- keeping_class_names_from_files : Rails . root . glob ( "app/views/**/*.*" ) + Rails . root . glob ( "app/helpers/**/*.rb" )
25- end
26-
2711 namespace :install do
2812 desc "Install Tailwind CSS with the asset pipeline"
2913 task :asset_pipeline do
@@ -35,4 +19,26 @@ namespace :tailwindcss do
3519 run_install_template "tailwindcss_with_webpacker"
3620 end
3721 end
22+
23+ desc "Show the list of class names being kept in Tailwind CSS"
24+ task :keeping_class_names do
25+ puts Tailwindcss ::Purger . extract_class_names_from ( default_files_with_class_names )
26+ end
27+
28+ desc "Show Tailwind CSS styles that are left after purging unused class names"
29+ task :preview_purge do
30+ puts Tailwindcss ::Purger . purge tailwind_css , keeping_class_names_from_files : default_files_with_class_names
31+ end
32+ end
33+
34+ def run_install_template ( path )
35+ system "#{ RbConfig . ruby } ./bin/rails app:template LOCATION=#{ File . expand_path ( "../install/#{ path } .rb" , __dir__ ) } "
36+ end
37+
38+ def default_files_with_class_names
39+ Rails . root . glob ( "app/views/**/*.*" ) + Rails . root . glob ( "app/helpers/**/*.rb" )
40+ end
41+
42+ def tailwind_css
43+ Pathname . new ( __FILE__ ) . join ( "../../../app/assets/stylesheets/tailwind.css" ) . read
3844end
0 commit comments