{"action":"created","issue":{"url":"https://api.github.com/repos/webpack/webpack/issues/1122","labels_url":"https://api.github.com/repos/webpack/webpack/issues/1122/labels{/name}","comments_url":"https://api.github.com/repos/webpack/webpack/issues/1122/comments","events_url":"https://api.github.com/repos/webpack/webpack/issues/1122/events","html_url":"https://github.com/webpack/webpack/issues/1122","id":81601013,"number":1122,"title":"Multiple targets","user":{"login":"jussi-kalliokoski","id":547186,"avatar_url":"https://avatars.githubusercontent.com/u/547186?v=3","gravatar_id":"","url":"https://api.github.com/users/jussi-kalliokoski","html_url":"https://github.com/jussi-kalliokoski","followers_url":"https://api.github.com/users/jussi-kalliokoski/followers","following_url":"https://api.github.com/users/jussi-kalliokoski/following{/other_user}","gists_url":"https://api.github.com/users/jussi-kalliokoski/gists{/gist_id}","starred_url":"https://api.github.com/users/jussi-kalliokoski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jussi-kalliokoski/subscriptions","organizations_url":"https://api.github.com/users/jussi-kalliokoski/orgs","repos_url":"https://api.github.com/users/jussi-kalliokoski/repos","events_url":"https://api.github.com/users/jussi-kalliokoski/events{/privacy}","received_events_url":"https://api.github.com/users/jussi-kalliokoski/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-27T19:59:34Z","updated_at":"2015-05-28T02:55:22Z","closed_at":null,"body":"This is mostly to open discussion on how to solve a specific problem at this point, I only have a crude idea in my head of how this could be made to work.\r\n\r\nI currently have an isomorphic website ([www.toons.tv](https://www.toons.tv)) that's built using React and Webpack on both the server and the client. The current build setup is quite clunky and accounts for a big portion of code in the whole project - the main reason for this is that in order to have an efficient development setup, I of course want to be watching all the assets and rebuild them when changed. However, every time the assets are rebuilt, the JS (both client and server) needs to know the new asset URLs. This means a very complex setup where webpack is only building the JS, and the rest (icon fonts, web fonts, images and other assets) is handled by gulp, and then all these update a `build-manifest.json` file that is required by the JS, so that the webpack builds are triggered as well.\r\n\r\nI'd like to move the asset pipeline completely to webpack instead, but this is problematic because currently you can only have one target (and set of options) per compiler, so the assets would be rebuilt twice and given that some of the assets are not generated deterministically (e.g. the icon fonts), the client could end up with different asset URLs than the server, which could easily lead to resources being loaded twice on the client.\r\n\r\nAt some point, I would also like to take service workers into use, and the worker would also need the same asset URLs.\r\n\r\nOne proposal that comes to mind is that you could define per-entry options:\r\n\r\n```javascript\r\nwebpack({\r\n  entry: {\r\n    client: {\r\n      entry: \"/path/to/client/entry.js\",\r\n      target: \"browser\",\r\n    },\r\n    server: {\r\n      entry: \"/path/to/server/entry.js\",\r\n      target: \"node\",\r\n    },\r\n  },\r\n});\r\n```\r\n\r\nI do realize that this would probably be a pain to implement, especially if the different entries are supposed to share parts of the pipeline while diverging at some points (e.g. if there's different plugins and/or loaders used by different entries), and also possibly require breaking changes to the plugin API, but I do hope to see this use case solved by webpack at some point.\r\n\r\nCheers! :heart: :sparkles:"},"comment":{"url":"https://api.github.com/repos/webpack/webpack/issues/comments/106154843","html_url":"https://github.com/webpack/webpack/issues/1122#issuecomment-106154843","issue_url":"https://api.github.com/repos/webpack/webpack/issues/1122","id":106154843,"user":{"login":"anyong","id":6260469,"avatar_url":"https://avatars.githubusercontent.com/u/6260469?v=3","gravatar_id":"","url":"https://api.github.com/users/anyong","html_url":"https://github.com/anyong","followers_url":"https://api.github.com/users/anyong/followers","following_url":"https://api.github.com/users/anyong/following{/other_user}","gists_url":"https://api.github.com/users/anyong/gists{/gist_id}","starred_url":"https://api.github.com/users/anyong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anyong/subscriptions","organizations_url":"https://api.github.com/users/anyong/orgs","repos_url":"https://api.github.com/users/anyong/repos","events_url":"https://api.github.com/users/anyong/events{/privacy}","received_events_url":"https://api.github.com/users/anyong/received_events","type":"User","site_admin":false},"created_at":"2015-05-28T02:55:22Z","updated_at":"2015-05-28T02:55:22Z","body":"Yeah I wish there was a better way to do this too. I'm currently running multiple webpack configurations in gulp tasks, but just today for some reason or other this stopped working and webpack won't watch my files anymore."}}