{"action":"created","comment":{"url":"https://api.github.com/repos/webpack/file-loader/pulls/comments/43576004","id":43576004,"diff_hunk":"@@ -14,7 +14,15 @@ module.exports = function(content) {\n \t\tcontent: content,\n \t\tregExp: query.regExp\n \t});\n+\tvar path = query.path;","path":"index.js","position":4,"original_position":4,"commit_id":"ac86db4445bf9a69909127ff156a50d0135aa7c1","original_commit_id":"ac86db4445bf9a69909127ff156a50d0135aa7c1","user":{"login":"hamczu","id":298715,"avatar_url":"https://avatars.githubusercontent.com/u/298715?v=3","gravatar_id":"","url":"https://api.github.com/users/hamczu","html_url":"https://github.com/hamczu","followers_url":"https://api.github.com/users/hamczu/followers","following_url":"https://api.github.com/users/hamczu/following{/other_user}","gists_url":"https://api.github.com/users/hamczu/gists{/gist_id}","starred_url":"https://api.github.com/users/hamczu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hamczu/subscriptions","organizations_url":"https://api.github.com/users/hamczu/orgs","repos_url":"https://api.github.com/users/hamczu/repos","events_url":"https://api.github.com/users/hamczu/events{/privacy}","received_events_url":"https://api.github.com/users/hamczu/received_events","type":"User","site_admin":false},"body":"I would use different name to avoid confusion with \"[path]\" placeholder - e.g. \"base\" or \"publicPath\"","created_at":"2015-10-31T20:45:56Z","updated_at":"2015-10-31T20:45:56Z","html_url":"https://github.com/webpack/file-loader/pull/42#discussion_r43576004","pull_request_url":"https://api.github.com/repos/webpack/file-loader/pulls/42","_links":{"self":{"href":"https://api.github.com/repos/webpack/file-loader/pulls/comments/43576004"},"html":{"href":"https://github.com/webpack/file-loader/pull/42#discussion_r43576004"},"pull_request":{"href":"https://api.github.com/repos/webpack/file-loader/pulls/42"}}},"pull_request":{"url":"https://api.github.com/repos/webpack/file-loader/pulls/42","id":48690123,"html_url":"https://github.com/webpack/file-loader/pull/42","diff_url":"https://github.com/webpack/file-loader/pull/42.diff","patch_url":"https://github.com/webpack/file-loader/pull/42.patch","issue_url":"https://api.github.com/repos/webpack/file-loader/issues/42","number":42,"state":"open","locked":false,"title":"Added a \"path\" query option","user":{"login":"jordansexton","id":1173161,"avatar_url":"https://avatars.githubusercontent.com/u/1173161?v=3","gravatar_id":"","url":"https://api.github.com/users/jordansexton","html_url":"https://github.com/jordansexton","followers_url":"https://api.github.com/users/jordansexton/followers","following_url":"https://api.github.com/users/jordansexton/following{/other_user}","gists_url":"https://api.github.com/users/jordansexton/gists{/gist_id}","starred_url":"https://api.github.com/users/jordansexton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jordansexton/subscriptions","organizations_url":"https://api.github.com/users/jordansexton/orgs","repos_url":"https://api.github.com/users/jordansexton/repos","events_url":"https://api.github.com/users/jordansexton/events{/privacy}","received_events_url":"https://api.github.com/users/jordansexton/received_events","type":"User","site_admin":false},"body":"For [domain sharding](http://abhishek-tiwari.com/post/CloudFront-design-patterns-and-best-practices) with hashed filenames, or splitting up build output assets by type or based on their source directories in a project, it's helpful to be able to differentiate the public path of the files emitted by the loader.\r\n\r\nThis PR is for a patch I've been using for a while now, and is a non-breaking change. I can also add tests for it if you like. It allows for a new query option, `path`, to be provided. `query.path` can be either a:\r\n\r\n- String (e.g. `https://static.cdn.net/`)\r\n\r\n  Since static assets are often served from a separate source than the application, this may be different from `options.output.publicPath`, and will be prepended to the output file path by the loader.\r\n\r\n- Function, taking a single `path` argument, the file path from the loader, e.g.:\r\n\r\n```javascript\r\nfunction shard (path) {\r\n    var hash = 0;\r\n    var digit;\r\n    for (var i = 0, length = path.length; i < length; i++) {\r\n        hash = (((hash << 5) - hash) + path.charCodeAt(i)) & 0xFFFFFFFF;\r\n    }\r\n    digit = Math.abs(hash % 10);\r\n    return 'https://static' + digit + '.cdn.net/' + path;\r\n};\r\n```\r\n\r\nThis allows assets to be sharded across domains based on a deterministic filename hash. Having deterministic output filenames is important for caching and linking of the assets (using React or another isomorphic rendering mechanism).","created_at":"2015-10-25T22:45:46Z","updated_at":"2015-10-31T20:45:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e523c780276d4f581a8c995fbe954ca7e71f6de4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/webpack/file-loader/pulls/42/commits","review_comments_url":"https://api.github.com/repos/webpack/file-loader/pulls/42/comments","review_comment_url":"https://api.github.com/repos/webpack/file-loader/pulls/comments{/number}","comments_url":"https://api.github.com/repos/webpack/file-loader/issues/42/comments","statuses_url":"https://api.github.com/repos/webpack/file-loader/statuses/ac86db4445bf9a69909127ff156a50d0135aa7c1","head":{"label":"jordansexton:query-path","ref":"query-path","sha":"ac86db4445bf9a69909127ff156a50d0135aa7c1","user":{"login":"jordansexton","id":1173161,"avatar_url":"https://avatars.githubusercontent.com/u/1173161?v=3","gravatar_id":"","url":"https://api.github.com/users/jordansexton","html_url":"https://github.com/jordansexton","followers_url":"https://api.github.com/users/jordansexton/followers","following_url":"https://api.github.com/users/jordansexton/following{/other_user}","gists_url":"https://api.github.com/users/jordansexton/gists{/gist_id}","starred_url":"https://api.github.com/users/jordansexton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jordansexton/subscriptions","organizations_url":"https://api.github.com/users/jordansexton/orgs","repos_url":"https://api.github.com/users/jordansexton/repos","events_url":"https://api.github.com/users/jordansexton/events{/privacy}","received_events_url":"https://api.github.com/users/jordansexton/received_events","type":"User","site_admin":false},"repo":{"id":38269555,"name":"file-loader","full_name":"jordansexton/file-loader","owner":{"login":"jordansexton","id":1173161,"avatar_url":"https://avatars.githubusercontent.com/u/1173161?v=3","gravatar_id":"","url":"https://api.github.com/users/jordansexton","html_url":"https://github.com/jordansexton","followers_url":"https://api.github.com/users/jordansexton/followers","following_url":"https://api.github.com/users/jordansexton/following{/other_user}","gists_url":"https://api.github.com/users/jordansexton/gists{/gist_id}","starred_url":"https://api.github.com/users/jordansexton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jordansexton/subscriptions","organizations_url":"https://api.github.com/users/jordansexton/orgs","repos_url":"https://api.github.com/users/jordansexton/repos","events_url":"https://api.github.com/users/jordansexton/events{/privacy}","received_events_url":"https://api.github.com/users/jordansexton/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jordansexton/file-loader","description":"file loader for webpack","fork":true,"url":"https://api.github.com/repos/jordansexton/file-loader","forks_url":"https://api.github.com/repos/jordansexton/file-loader/forks","keys_url":"https://api.github.com/repos/jordansexton/file-loader/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jordansexton/file-loader/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jordansexton/file-loader/teams","hooks_url":"https://api.github.com/repos/jordansexton/file-loader/hooks","issue_events_url":"https://api.github.com/repos/jordansexton/file-loader/issues/events{/number}","events_url":"https://api.github.com/repos/jordansexton/file-loader/events","assignees_url":"https://api.github.com/repos/jordansexton/file-loader/assignees{/user}","branches_url":"https://api.github.com/repos/jordansexton/file-loader/branches{/branch}","tags_url":"https://api.github.com/repos/jordansexton/file-loader/tags","blobs_url":"https://api.github.com/repos/jordansexton/file-loader/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jordansexton/file-loader/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jordansexton/file-loader/git/refs{/sha}","trees_url":"https://api.github.com/repos/jordansexton/file-loader/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jordansexton/file-loader/statuses/{sha}","languages_url":"https://api.github.com/repos/jordansexton/file-loader/languages","stargazers_url":"https://api.github.com/repos/jordansexton/file-loader/stargazers","contributors_url":"https://api.github.com/repos/jordansexton/file-loader/contributors","subscribers_url":"https://api.github.com/repos/jordansexton/file-loader/subscribers","subscription_url":"https://api.github.com/repos/jordansexton/file-loader/subscription","commits_url":"https://api.github.com/repos/jordansexton/file-loader/commits{/sha}","git_commits_url":"https://api.github.com/repos/jordansexton/file-loader/git/commits{/sha}","comments_url":"https://api.github.com/repos/jordansexton/file-loader/comments{/number}","issue_comment_url":"https://api.github.com/repos/jordansexton/file-loader/issues/comments{/number}","contents_url":"https://api.github.com/repos/jordansexton/file-loader/contents/{+path}","compare_url":"https://api.github.com/repos/jordansexton/file-loader/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jordansexton/file-loader/merges","archive_url":"https://api.github.com/repos/jordansexton/file-loader/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jordansexton/file-loader/downloads","issues_url":"https://api.github.com/repos/jordansexton/file-loader/issues{/number}","pulls_url":"https://api.github.com/repos/jordansexton/file-loader/pulls{/number}","milestones_url":"https://api.github.com/repos/jordansexton/file-loader/milestones{/number}","notifications_url":"https://api.github.com/repos/jordansexton/file-loader/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jordansexton/file-loader/labels{/name}","releases_url":"https://api.github.com/repos/jordansexton/file-loader/releases{/id}","created_at":"2015-06-29T20:27:16Z","updated_at":"2015-06-29T20:27:17Z","pushed_at":"2015-10-25T22:57:31Z","git_url":"git://github.com/jordansexton/file-loader.git","ssh_url":"git@github.com:jordansexton/file-loader.git","clone_url":"https://github.com/jordansexton/file-loader.git","svn_url":"https://github.com/jordansexton/file-loader","homepage":null,"size":125,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"webpack:master","ref":"master","sha":"9cda561d2497c2e0668b2a797733b6d8fcc402ca","user":{"login":"webpack","id":2105791,"avatar_url":"https://avatars.githubusercontent.com/u/2105791?v=3","gravatar_id":"","url":"https://api.github.com/users/webpack","html_url":"https://github.com/webpack","followers_url":"https://api.github.com/users/webpack/followers","following_url":"https://api.github.com/users/webpack/following{/other_user}","gists_url":"https://api.github.com/users/webpack/gists{/gist_id}","starred_url":"https://api.github.com/users/webpack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webpack/subscriptions","organizations_url":"https://api.github.com/users/webpack/orgs","repos_url":"https://api.github.com/users/webpack/repos","events_url":"https://api.github.com/users/webpack/events{/privacy}","received_events_url":"https://api.github.com/users/webpack/received_events","type":"Organization","site_admin":false},"repo":{"id":4253587,"name":"file-loader","full_name":"webpack/file-loader","owner":{"login":"webpack","id":2105791,"avatar_url":"https://avatars.githubusercontent.com/u/2105791?v=3","gravatar_id":"","url":"https://api.github.com/users/webpack","html_url":"https://github.com/webpack","followers_url":"https://api.github.com/users/webpack/followers","following_url":"https://api.github.com/users/webpack/following{/other_user}","gists_url":"https://api.github.com/users/webpack/gists{/gist_id}","starred_url":"https://api.github.com/users/webpack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webpack/subscriptions","organizations_url":"https://api.github.com/users/webpack/orgs","repos_url":"https://api.github.com/users/webpack/repos","events_url":"https://api.github.com/users/webpack/events{/privacy}","received_events_url":"https://api.github.com/users/webpack/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/webpack/file-loader","description":"file loader for webpack","fork":false,"url":"https://api.github.com/repos/webpack/file-loader","forks_url":"https://api.github.com/repos/webpack/file-loader/forks","keys_url":"https://api.github.com/repos/webpack/file-loader/keys{/key_id}","collaborators_url":"https://api.github.com/repos/webpack/file-loader/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/webpack/file-loader/teams","hooks_url":"https://api.github.com/repos/webpack/file-loader/hooks","issue_events_url":"https://api.github.com/repos/webpack/file-loader/issues/events{/number}","events_url":"https://api.github.com/repos/webpack/file-loader/events","assignees_url":"https://api.github.com/repos/webpack/file-loader/assignees{/user}","branches_url":"https://api.github.com/repos/webpack/file-loader/branches{/branch}","tags_url":"https://api.github.com/repos/webpack/file-loader/tags","blobs_url":"https://api.github.com/repos/webpack/file-loader/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/webpack/file-loader/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/webpack/file-loader/git/refs{/sha}","trees_url":"https://api.github.com/repos/webpack/file-loader/git/trees{/sha}","statuses_url":"https://api.github.com/repos/webpack/file-loader/statuses/{sha}","languages_url":"https://api.github.com/repos/webpack/file-loader/languages","stargazers_url":"https://api.github.com/repos/webpack/file-loader/stargazers","contributors_url":"https://api.github.com/repos/webpack/file-loader/contributors","subscribers_url":"https://api.github.com/repos/webpack/file-loader/subscribers","subscription_url":"https://api.github.com/repos/webpack/file-loader/subscription","commits_url":"https://api.github.com/repos/webpack/file-loader/commits{/sha}","git_commits_url":"https://api.github.com/repos/webpack/file-loader/git/commits{/sha}","comments_url":"https://api.github.com/repos/webpack/file-loader/comments{/number}","issue_comment_url":"https://api.github.com/repos/webpack/file-loader/issues/comments{/number}","contents_url":"https://api.github.com/repos/webpack/file-loader/contents/{+path}","compare_url":"https://api.github.com/repos/webpack/file-loader/compare/{base}...{head}","merges_url":"https://api.github.com/repos/webpack/file-loader/merges","archive_url":"https://api.github.com/repos/webpack/file-loader/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/webpack/file-loader/downloads","issues_url":"https://api.github.com/repos/webpack/file-loader/issues{/number}","pulls_url":"https://api.github.com/repos/webpack/file-loader/pulls{/number}","milestones_url":"https://api.github.com/repos/webpack/file-loader/milestones{/number}","notifications_url":"https://api.github.com/repos/webpack/file-loader/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/webpack/file-loader/labels{/name}","releases_url":"https://api.github.com/repos/webpack/file-loader/releases{/id}","created_at":"2012-05-07T20:13:12Z","updated_at":"2015-10-30T13:01:42Z","pushed_at":"2015-10-25T22:57:31Z","git_url":"git://github.com/webpack/file-loader.git","ssh_url":"git@github.com:webpack/file-loader.git","clone_url":"https://github.com/webpack/file-loader.git","svn_url":"https://github.com/webpack/file-loader","homepage":null,"size":356,"stargazers_count":86,"watchers_count":86,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":26,"forks":28,"open_issues":26,"watchers":86,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/webpack/file-loader/pulls/42"},"html":{"href":"https://github.com/webpack/file-loader/pull/42"},"issue":{"href":"https://api.github.com/repos/webpack/file-loader/issues/42"},"comments":{"href":"https://api.github.com/repos/webpack/file-loader/issues/42/comments"},"review_comments":{"href":"https://api.github.com/repos/webpack/file-loader/pulls/42/comments"},"review_comment":{"href":"https://api.github.com/repos/webpack/file-loader/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/webpack/file-loader/pulls/42/commits"},"statuses":{"href":"https://api.github.com/repos/webpack/file-loader/statuses/ac86db4445bf9a69909127ff156a50d0135aa7c1"}}}}