{"action":"created","issue":{"url":"https://api.github.com/repos/rails/webpacker/issues/691","repository_url":"https://api.github.com/repos/rails/webpacker","labels_url":"https://api.github.com/repos/rails/webpacker/issues/691/labels{/name}","comments_url":"https://api.github.com/repos/rails/webpacker/issues/691/comments","events_url":"https://api.github.com/repos/rails/webpacker/issues/691/events","html_url":"https://github.com/rails/webpacker/issues/691","id":252587365,"number":691,"title":"Pass custom environment variables to the compiler","user":{"login":"sjchmiela","id":1151041,"avatar_url":"https://avatars2.githubusercontent.com/u/1151041?v=4","gravatar_id":"","url":"https://api.github.com/users/sjchmiela","html_url":"https://github.com/sjchmiela","followers_url":"https://api.github.com/users/sjchmiela/followers","following_url":"https://api.github.com/users/sjchmiela/following{/other_user}","gists_url":"https://api.github.com/users/sjchmiela/gists{/gist_id}","starred_url":"https://api.github.com/users/sjchmiela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjchmiela/subscriptions","organizations_url":"https://api.github.com/users/sjchmiela/orgs","repos_url":"https://api.github.com/users/sjchmiela/repos","events_url":"https://api.github.com/users/sjchmiela/events{/privacy}","received_events_url":"https://api.github.com/users/sjchmiela/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-08-24T12:36:17Z","updated_at":"2018-02-12T18:41:32Z","closed_at":"2017-08-24T20:31:31Z","author_association":"CONTRIBUTOR","body":"Given deployment flow using Capistrano, one would like to pass custom environment variables, like current revision hash or some access tokens (to upload source map to Rollbar or API key for Google Maps) to Webpack, so it can compile them into generated code.\r\n\r\nI suppose it could be done by extending [`webpack_env`](https://github.com/rails/webpacker/blame/master/lib/webpacker/compiler.rb#L71) method on `Webpacker::Compiler`?"},"comment":{"url":"https://api.github.com/repos/rails/webpacker/issues/comments/365020671","html_url":"https://github.com/rails/webpacker/issues/691#issuecomment-365020671","issue_url":"https://api.github.com/repos/rails/webpacker/issues/691","id":365020671,"user":{"login":"sjchmiela","id":1151041,"avatar_url":"https://avatars2.githubusercontent.com/u/1151041?v=4","gravatar_id":"","url":"https://api.github.com/users/sjchmiela","html_url":"https://github.com/sjchmiela","followers_url":"https://api.github.com/users/sjchmiela/followers","following_url":"https://api.github.com/users/sjchmiela/following{/other_user}","gists_url":"https://api.github.com/users/sjchmiela/gists{/gist_id}","starred_url":"https://api.github.com/users/sjchmiela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjchmiela/subscriptions","organizations_url":"https://api.github.com/users/sjchmiela/orgs","repos_url":"https://api.github.com/users/sjchmiela/repos","events_url":"https://api.github.com/users/sjchmiela/events{/privacy}","received_events_url":"https://api.github.com/users/sjchmiela/received_events","type":"User","site_admin":false},"created_at":"2018-02-12T18:41:32Z","updated_at":"2018-02-12T18:41:32Z","author_association":"CONTRIBUTOR","body":"I've ended up using something similar:\r\n\r\n```rb\r\n# config/initializers/revision.rb\r\ngit_sha, = Open3.capture3('git rev-parse HEAD')\r\nrevision, _, revision_status = Open3.capture3('cat REVISION')\r\n\r\nHealthNation::Application::REVISION =\r\n  if revision_status.success?\r\n    revision.chomp\r\n  else\r\n    git_sha.chomp\r\n  end\r\n```\r\n\r\nand in `initializers/webpacker.rb`\r\n\r\n```rb\r\nWebpacker::Compiler.env['VERSION'] = HealthNation::Application::REVISION\r\n```"}}
{"actor":{"display_login":"sjchmiela"}}