{"action":"created","issue":{"url":"https://api.github.com/repos/mariusbalcytis/webpack-bundle/issues/7","repository_url":"https://api.github.com/repos/mariusbalcytis/webpack-bundle","labels_url":"https://api.github.com/repos/mariusbalcytis/webpack-bundle/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/mariusbalcytis/webpack-bundle/issues/7/comments","events_url":"https://api.github.com/repos/mariusbalcytis/webpack-bundle/issues/7/events","html_url":"https://github.com/mariusbalcytis/webpack-bundle/issues/7","id":162752503,"number":7,"title":"Loading Images","user":{"login":"jorge-marques","id":1558256,"avatar_url":"https://avatars.githubusercontent.com/u/1558256?v=3","gravatar_id":"","url":"https://api.github.com/users/jorge-marques","html_url":"https://github.com/jorge-marques","followers_url":"https://api.github.com/users/jorge-marques/followers","following_url":"https://api.github.com/users/jorge-marques/following{/other_user}","gists_url":"https://api.github.com/users/jorge-marques/gists{/gist_id}","starred_url":"https://api.github.com/users/jorge-marques/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jorge-marques/subscriptions","organizations_url":"https://api.github.com/users/jorge-marques/orgs","repos_url":"https://api.github.com/users/jorge-marques/repos","events_url":"https://api.github.com/users/jorge-marques/events{/privacy}","received_events_url":"https://api.github.com/users/jorge-marques/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-06-28T18:21:34Z","updated_at":"2016-06-28T22:04:33Z","closed_at":null,"body":"Can the webpack_asset function be used to load images?"},"comment":{"url":"https://api.github.com/repos/mariusbalcytis/webpack-bundle/issues/comments/229198527","html_url":"https://github.com/mariusbalcytis/webpack-bundle/issues/7#issuecomment-229198527","issue_url":"https://api.github.com/repos/mariusbalcytis/webpack-bundle/issues/7","id":229198527,"user":{"login":"mariusbalcytis","id":1590072,"avatar_url":"https://avatars.githubusercontent.com/u/1590072?v=3","gravatar_id":"","url":"https://api.github.com/users/mariusbalcytis","html_url":"https://github.com/mariusbalcytis","followers_url":"https://api.github.com/users/mariusbalcytis/followers","following_url":"https://api.github.com/users/mariusbalcytis/following{/other_user}","gists_url":"https://api.github.com/users/mariusbalcytis/gists{/gist_id}","starred_url":"https://api.github.com/users/mariusbalcytis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mariusbalcytis/subscriptions","organizations_url":"https://api.github.com/users/mariusbalcytis/orgs","repos_url":"https://api.github.com/users/mariusbalcytis/repos","events_url":"https://api.github.com/users/mariusbalcytis/events{/privacy}","received_events_url":"https://api.github.com/users/mariusbalcytis/received_events","type":"User","site_admin":false},"created_at":"2016-06-28T22:04:32Z","updated_at":"2016-06-28T22:04:32Z","body":"No, not out of the box.\r\n\r\nThe issue is that every webpack module is javascript file by default. So either you `require('image.png')` or put `image.png` as an entry point (read \"inside `webpack_asset` function\"), webpack generates javascript file with `module.exports = 'file_path.png';` somewhere in it (and javascript is not valid picture file).\r\n\r\nIt could be possible if using additional plugins like [extract-text-webpack-plugin](https://github.com/webpack/extract-text-webpack-plugin) (see [this issue](\r\nhttps://github.com/webpack/webpack/issues/170) for discussion).\r\nIt's already configured for css files in this bundle (see example in readme) - same story would go for images.\r\nI played a little with this idea - unfortulatelly, it looks like plug-in doesn't support binary content.\r\n\r\nSo, to make it work, one would need to:\r\n1. Make extract-text-webpack-plugin work with binary content\r\n2. Configure `app/config/webpack.config.js` to use it for images (possibly few instances of plugin may be needed - for images and css files)\r\n3. Pass second argument to `webpack_asset` to take correct file (not default JS one)\r\n\r\n---\r\n\r\nOn the other hand, webpack is really brilliant when you are making single-page application. If that's the case, you can still use image loading with `require` inside your javascript files and add them dynamically when needed."}}
{"actor":{"display_login":"mariusbalcytis"}}