Skip to content

DRY default_files_with_class_names list of folders #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions lib/tailwindcss/compressor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def self.call(input)

def initialize(options = {})
@options = {
files_with_class_names: files_with_class_names,
files_with_class_names: Tailwindcss::Purger.default_files_with_class_names,
only_purge: %w[ tailwind ]
}.merge(options).freeze
end
Expand All @@ -23,11 +23,4 @@ def call(input)
input[:data]
end
end

private
def files_with_class_names
Rails.root.glob("app/views/**/*.*") +
Rails.root.glob("app/helpers/**/*.rb") +
Rails.root.glob("app/javascript/**/*.js")
end
end
6 changes: 6 additions & 0 deletions lib/tailwindcss/purger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ def extract_class_names_from(files)
def escape_class_selector(class_name)
class_name.gsub(/\A\d|[^-_a-z0-9]/, '\\\\\0')
end

def default_files_with_class_names
Rails.root.glob("app/views/**/*.*") +
Rails.root.glob("app/helpers/**/*.rb") +
Rails.root.glob("app/javascript/**/*.js")
end
end

def initialize(keep_these_class_names)
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/tailwindcss_tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace :tailwindcss do
end

def default_files_with_class_names
Rails.root.glob("app/views/**/*.*") + Rails.root.glob("app/helpers/**/*.rb")
Tailwindcss::Purger.default_files_with_class_names
end

def tailwind_css
Expand Down