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
-
5
1
namespace :tailwindcss do
6
2
desc "Install Tailwind CSS into the app"
7
3
task :install do
@@ -12,18 +8,6 @@ namespace :tailwindcss do
12
8
end
13
9
end
14
10
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
-
27
11
namespace :install do
28
12
desc "Install Tailwind CSS with the asset pipeline"
29
13
task :asset_pipeline do
@@ -35,4 +19,26 @@ namespace :tailwindcss do
35
19
run_install_template "tailwindcss_with_webpacker"
36
20
end
37
21
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
38
44
end
0 commit comments