{"id":31271777,"url":"https://github.com/hschne/browserslist-rb","last_synced_at":"2025-11-11T18:16:28.378Z","repository":{"id":311924788,"uuid":"1045615504","full_name":"hschne/browserslist-rb","owner":"hschne","description":"Bringing browserslist  to Ruby! 🌍💎","archived":false,"fork":false,"pushed_at":"2025-08-28T12:43:41.000Z","size":34,"stargazers_count":20,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-23T20:12:56.296Z","etag":null,"topics":["browserslist","esbuild","ruby","ruby-on-rails","rubygem","vite"],"latest_commit_sha":null,"homepage":"","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/hschne.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-27T13:06:25.000Z","updated_at":"2025-09-20T20:39:06.000Z","dependencies_parsed_at":"2025-08-27T22:48:36.636Z","dependency_job_id":null,"html_url":"https://github.com/hschne/browserslist-rb","commit_stats":null,"previous_names":["hschne/browserslist-rb"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/hschne/browserslist-rb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hschne%2Fbrowserslist-rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hschne%2Fbrowserslist-rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hschne%2Fbrowserslist-rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hschne%2Fbrowserslist-rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hschne","download_url":"https://codeload.github.com/hschne/browserslist-rb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hschne%2Fbrowserslist-rb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278572004,"owners_count":26008686,"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","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["browserslist","esbuild","ruby","ruby-on-rails","rubygem","vite"],"created_at":"2025-09-23T20:02:13.215Z","updated_at":"2025-10-06T06:55:14.483Z","avatar_url":"https://github.com/hschne.png","language":"Ruby","readme":"# Browserslist Ruby\n\nBring [browserslist](https://github.com/browserslist/browserslist) to Ruby. \n\nSince Rails 8.0, you can use [allowed browsers](https://github.com/rails/rails/pull/50505) to block access to your application for specific browsers. This gem allows you to integrate your existing Browserlist configuration into Rails. \n\n```ruby\nallow_browser versions: Browserslist.browsers\n```\n\n## Installation\n\nAdd `browserslist` to your `Gemfile`:\n\n```bash\nbundle add browserslist\n```\n\n## Usage\n\n### Generating a Browserslist\n\n`browserslist-rb` reads from a `.browserslist.json` file that must be generated upfront or at build time. This gem ships with a generator that requires `npm/npx` to be installed. If you generate the file upfront you must make sure it's available at runtime.\n\n```bash\n# Generate default .browserslist.json file\nbundle exec browserslist generate\n```\n\n#### Build-Time Generation\n\nFor Rails applications using modern bundlers, you can generate the browserslist file at build time, depending on your tooling.\n\n\u003cdetails\u003e\n\u003csummary\u003eAsset Precompilation\u003c/summary\u003e\n\nYou may use the built-in rake task to hook into your asset precompilation process. First require the Rake tasks, then enhance your asset precompilation. Add this to your `lib/tasks/assets.rake`:\n\n```ruby\nrequire 'browserslist/rake'\n\nRake::Task['assets:precompile'].enhance(['browserslist:update'])\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eVite Ruby\u003c/summary\u003e\n\nAdd to `vite.config.ts` using a plugin:\n\n```typescript\nimport { defineConfig } from 'vite'\nimport { execSync } from 'child_process'\n\nexport default defineConfig({\n  plugins: [\n    {\n      name: 'browserslist-generator',\n      configResolved() {\n        execSync('npx browserslist --json \u003e .browserslist.json')\n      }\n    }\n  ]\n})\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eesbuild\u003c/summary\u003e\n\nUse a build plugin in your esbuild configuration:\n\n```javascript\nrequire('esbuild').build({\n  plugins: [{\n    name: 'browserslist-generator',\n    setup(build) {\n      build.onStart(() =\u003e {\n        const browserslist = require('browserslist')\n        const fs = require('fs')\n        fs.writeFileSync('./.browserslist.json', JSON.stringify(browserslist()))\n      })\n    }\n  }]\n})\n```\n\u003c/details\u003e\n\n\n### Using the API\n\nOnce you have generated your browserslist file, the gem provides a hash of minimum required browser versions:\n\n```ruby\nBrowserslist.browsers\n# =\u003e {chrome: 119.0, firefox: 128.0, edge: 138.0, safari: 18.4, opera: 80.0, ie: false}\n```\nFor example with Rails 8.0+ allowed browsers:\n\n```ruby\nallow_browser versions: Browserslist.browsers\n```\n\nYou may preview the resulting hash using \n\n```bash\nbundle exec browserslist browsers\n# =\u003e {chrome: 119.0, firefox: 128.0, edge: 138.0, safari: 18.4, opera: 80.0, ie: false}\n```\n\n\n## Configuration\n\nConfigure the gem like so:\n\n```ruby\nBrowserslist.configure do |config|\n  # Set custom file path \n  config.file_path = \".browserslist.json\"\n  \n  # Enable/disable strict mode \n  # When strict mode is enabled, missing browsers hash value will be set to false, which in conjunction with `allow_browser` means they will be forbidden from accessing your application.\n  config.strict = true\nend\n```\n\n## Browser Support\n\nThe gem supports these browsers:\n- **Chrome** (`chrome`, `and_chr`)\n- **Firefox** (`firefox`, `and_ff`) \n- **Safari** (`safari`, `ios_saf`)\n- **Edge** (`edge`)\n- **Opera** (`opera`, `op_mob`)\n- **Internet Explorer** (`ie`)\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt.\n\nTo install this gem onto your local machine, run `bundle exec rake install`.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/hschne/browserslist-rb.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhschne%2Fbrowserslist-rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhschne%2Fbrowserslist-rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhschne%2Fbrowserslist-rb/lists"}