{"id":22428735,"url":"https://github.com/tlatsas/webpacker_uploader","last_synced_at":"2025-09-08T22:31:50.001Z","repository":{"id":39678706,"uuid":"297255650","full_name":"tlatsas/webpacker_uploader","owner":"tlatsas","description":"Upload webpack(-er) generated assets to the cloud","archived":false,"fork":false,"pushed_at":"2023-08-24T02:50:18.000Z","size":128,"stargazers_count":5,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-26T07:02:50.034Z","etag":null,"topics":["assets","cloud","frontend","rails","ruby","s3-cdn","webpacker"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/webpacker_uploader","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/tlatsas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"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}},"created_at":"2020-09-21T07:01:44.000Z","updated_at":"2024-08-05T18:22:54.533Z","dependencies_parsed_at":"2024-08-05T18:35:34.230Z","dependency_job_id":null,"html_url":"https://github.com/tlatsas/webpacker_uploader","commit_stats":{"total_commits":83,"total_committers":8,"mean_commits":10.375,"dds":0.5180722891566265,"last_synced_commit":"c20f1bcc4f0b6d54c4b092a7d9b39cd39e630c8f"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tlatsas%2Fwebpacker_uploader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tlatsas%2Fwebpacker_uploader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tlatsas%2Fwebpacker_uploader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tlatsas%2Fwebpacker_uploader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tlatsas","download_url":"https://codeload.github.com/tlatsas/webpacker_uploader/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232182959,"owners_count":18484710,"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":["assets","cloud","frontend","rails","ruby","s3-cdn","webpacker"],"created_at":"2024-12-05T20:16:52.108Z","updated_at":"2025-01-03T15:36:23.055Z","avatar_url":"https://github.com/tlatsas.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebpackerUploader\n\n[![Ruby tests](https://img.shields.io/github/actions/workflow/status/tlatsas/webpacker_uploader/ruby.yml?style=flat-square)](https://github.com/tlatsas/webpacker_uploader/actions)\n[![RuboCop](https://img.shields.io/github/actions/workflow/status/tlatsas/webpacker_uploader/rubocop.yml?label=rubocop\u0026style=flat-square)](https://github.com/tlatsas/webpacker_uploader/actions)\n[![Gem](https://img.shields.io/gem/v/webpacker_uploader?style=flat-square)](https://rubygems.org/gems/webpacker_uploader)\n[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg?style=flat-square)](https://www.rubydoc.info/gems/webpacker_uploader)\n\nWebpacker uploader provides an easy way to upload your assets to AWS S3.\nIt knows which files to upload by reading the `manifest.json` file.\n\nThis is particularly useful if you serve your application's assets through a combination of\nS3 + CDN, outside of your Rails application.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"webpacker_uploader\", require: false\n```\n\nand run:\n\n```sh\nbundle install\n```\n\nor:\n\n```sh\ngem install webpacker_uploader\n```\n\nTo use the aws provider install the aws-sdk-s3 gem. Add in your Gemfile:\n\n```ruby\ngem \"aws-sdk-s3\", require: false\n```\n\n## Usage\n\nUsually, in a Rake task you would add the following to upload the assets to AWS S3:\n\n```ruby\nrequire \"webpacker_uploader\"\nrequire \"webpacker_uploader/providers/aws\"\n\nprovider_options = {\n  credentials: { profile_name: \"staging\" },\n  region: \"eu-central-1\",\n  bucket: \"application-assets-20200929124523451600000001\"\n}\n\nprovider = WebpackerUploader::Providers::Aws.new(provider_options)\nWebpackerUploader.upload!(provider)\n```\n\nCurrently, the only provider implemented is the AWS S3 provider.\n\n### AWS S3 provider\n\nThe AWS S3 provider credentials can be configured in three ways.\nPassing a named profile name:\n\n```ruby\nprovider_options = {\n  credentials: { profile_name: \"staging\" },\n  region: \"eu-central-1\",\n  bucket: \"application-assets-20200929124523451600000001\"\n}\n\nprovider = WebpackerUploader::Providers::Aws.new(provider_options)\n```\n\npassing the access and the secret keys directly:\n\n```ruby\nprovider_options = {\n  credentials: { access_key_id: \"AKIAIOSFODNN7EXAMPLE\", secret_access_key: \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY\" },\n  region: \"eu-central-1\",\n  bucket: \"application-assets-20200929124523451600000001\"\n}\n\nprovider = WebpackerUploader::Providers::Aws.new(provider_options)\n```\n\nor using an EC2 instance profile:\n\n```ruby\nprovider_options = {\n  credentials: { instance_profile: true },\n  region: \"eu-central-1\",\n  bucket: \"application-assets-20200929124523451600000001\"\n}\n\nprovider = WebpackerUploader::Providers::Aws.new(provider_options)\n```\n\n### Prefix remote files\n\nUploaded files can be prefixed by setting the `prefix` parameter during upload:\n\n```ruby\nWebpackerUploader.upload!(provider, prefix: \"assets\")\n```\n\nThis will prefix all remote file paths with `assets` so instead of storing `packs/application-dd6b1cd38bfa093df600.css` it\nwill store `assets/packs/application-dd6b1cd38bfa093df600.css`.\n\n### Add a cache-control directive to remote files\n\n```ruby\nWebpackerUploader.upload!(provider, cache_control: \"public, max-age=3600\")\n```\n\nThis option is used to specify caching behavior along the request/reply chain.\n\n```text\n⚠️ This option is applied to all uploaded files, not on a per-file basis.\n```\n\n### Configuration\n\nWebpackerUploader currently supports the following configuration options:\n\n| option               | description                                                  | default value                         |\n| -------------------- | ------------------------------------------------------------ | ------------------------------------- |\n| ignored_extensions   | Which files uploader should skip based on the file extension | []                                    |\n| logger               | The logger to use for logging                                | ActiveSupport::Logger.new(STDOUT)     |\n| log_output           | Log output as we upload files                                | true                                  |\n| public_manifest_path | The webpack manifest path                                    | Webpacker.config.public_manifest_path |\n| public_path          | The webpack public output path                               | Webpacker.config.public_path          |\n\nIt can be configured using a block:\n\n```ruby\nWebpackerUploader.configure do |config|\n  config.ignored_extensions = [\".png\", \".jpg\", \".webp\"]\n  config.log_output = false\n  config.public_manifest_path = \"path/to/manifest.json\"\n  config.public_path = \"path/to/public/dir\"\nend\n```\n\nor directly:\n\n```ruby\nWebpackerUploader.config.log_output = false\n```\n\nThe uploader used to skip `.map` files by default. This has changed (see [CHANGELOG.md](https://github.com/tlatsas/webpacker_uploader/blob/main/CHANGELOG.md))\nand everything is uploaded by default now. To retain the previous functionality use:\n\n```ruby\n# skip uploading map files\nWebpackerUploader.config.ignored_extensions = [\".map\"]\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies.\nThen, run `rake test` to run the tests. You can also run `bin/console` for an\ninteractive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`.\n\n## Integration tests\n\nThis gem also provides an integration test suite. It runs using [localstack](https://github.com/localstack/localstack/).\nTo run the integration tests, install docker on your system and spin up a localstack container running the s3 service.\n\n```shell\ndocker compose -f \"integration/docker-compose.yml\" up --detach\n```\n\nTo run the tests, use `rake test:integration`.\n\nTo stop the container once done run: `docker-compose -f \"integration/docker-compose.yml\" down`\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/tlatsas/webpacker_uploader.\n\nSee [CONTRIBUTING](CONTRIBUTING.md).\n\n## License\n\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%2Ftlatsas%2Fwebpacker_uploader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftlatsas%2Fwebpacker_uploader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftlatsas%2Fwebpacker_uploader/lists"}