{"id":18751222,"url":"https://github.com/sebyx07/purgecss_rails","last_synced_at":"2025-04-13T00:08:36.143Z","repository":{"id":40227775,"uuid":"188299283","full_name":"sebyx07/purgecss_rails","owner":"sebyx07","description":"PurgeCSS for Rails Asset Pipeline","archived":false,"fork":false,"pushed_at":"2023-01-19T13:02:44.000Z","size":53,"stargazers_count":3,"open_issues_count":9,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T00:08:35.850Z","etag":null,"topics":["css","performance","purgecss","rails","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sebyx07.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-23T20:07:47.000Z","updated_at":"2022-10-26T09:59:20.000Z","dependencies_parsed_at":"2023-02-11T00:20:39.508Z","dependency_job_id":null,"html_url":"https://github.com/sebyx07/purgecss_rails","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebyx07%2Fpurgecss_rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebyx07%2Fpurgecss_rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebyx07%2Fpurgecss_rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebyx07%2Fpurgecss_rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebyx07","download_url":"https://codeload.github.com/sebyx07/purgecss_rails/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647299,"owners_count":21139086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","performance","purgecss","rails","ruby"],"created_at":"2024-11-07T17:14:58.731Z","updated_at":"2025-04-13T00:08:36.120Z","avatar_url":"https://github.com/sebyx07.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PurgecssRails\nReduce the bloat in your Rails CSS files using PurgeCSS. You can easily configure it to work with most rails apps.\n\n## Installation\n\nFirst you would need a `purgecss` executable.\nyou can easily add by:\n\n```bash\nyarn add purgecss\n```\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'purgecss_rails', require: false\n```\n\nAnd then execute:\n```bash\n$ bundle\n```\n\nOr install it yourself as:\n```bash\n$ gem install purgecss_rails\n```\n\n## Usage\n\nDefine a file lib/tasks/purge_css.rake and put:\n\n```ruby\nrequire \"purgecss_rails\"\n\nnamespace :purge_css do\n  desc \"Clear previous CSS files, this busts the CSS cache\"\n  task :clear do\n    `rm public/assets/*.css -rf`\n    `rm public/assets/*.css.gz -rf`\n  end\n\n  desc \"Optimize css files with PurgeCSS\"\n  task :run do\n    PurgecssRails.configure(purge_css_path: \"node_modules/purgecss/bin/purgecss\") do |purge|\n      purge.search_css_files(\"public/assets/**/*.css\")\n\n      purge.match_html_files \"public/assets/**/*.js\",\n                             \"app/views/**/*.html.erb\",\n                             \"app/helpers/**/*.rb\"\n\n      purge.optimize!\n    end.enable!.run_now!\n  end\nend\n```\n\nIf you need more precision in purging the css, ex engines:\n\n```ruby\nPurgecssRails.configure(purge_css_path: `purgecss`) do |purge|\n  purge.search_css_files(\"public/assets/my_engine/application.css\")\n\n  purge.match_html_files \"public/assets/my_engine/application.js\",\n                         \"engines/my_engine/views/**/*.html.erb\",\n                         \"app/helpers/**/*.rb\"\n\n  purge.optimize!\nend.enable!.run_now!\n```\n\nWhen you are using an external engine and you don't want to purge their css file, add a ingore\n```ruby\n  purge.search_css_files(\"public/assets/**/*.css\", ignore: ['rails_admin'])    \n```\n\n\nyou can also call `purge.refresh!` and reuse the the `purge` object\n\n## Deployment\n\nHeroku Procfile example\n\n`release: rake purge_css:clear assets:precompile purge_css:run`\n\nOther\n\n`rake purge_css:clear assets:precompile purge_css:run`\n\n## License\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebyx07%2Fpurgecss_rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebyx07%2Fpurgecss_rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebyx07%2Fpurgecss_rails/lists"}