title: In webpack, how can I have different output directories for multiple entry points?
body: <p>I have the following webpack configuration with multiple entry points...</p>
  
  <pre><code>module.exports = {
   entry: {
    somePage: "./scripts/someDir/somePage.js",
    anotherPage: "./scripts/someDir/someSubDir/anotherPage.js"
   },
   output: {
     path: path.resolve(__dirname, 'out'),
     filename: '[name].js'
   },
   ...
  </code></pre>
  
  <p>Is it possible to set a different output path for each entry? </p>
  
  <p>Instead of getting an output of... </p>
  
  <p><code>/out/somePage.js
  /out/anotherPage.js</code> </p>
  
  <p>I want... </p>
  
  <p><code>/out/someDir/somePage.js
  /out/someDir/someSubDir/anotherPage.js</code></p>
  
  <p>The ideal solution for me would be for <code>output.path</code> to accept a function. For example...</p>
  
  <pre><code>...
  output: {
     path: function (name, hash) {
         return path.resolve(__dirname, myMapOfFilenamesToDirs[name]);
     },
     filename: '[name].js'
  },
  </code></pre>
  
  <p>Does anyone know if this is possible or if there is an existing plugin that can accomplish this?</p>
  
  <p><strong>EDIT</strong> I don't want to use multiple config entries (multi-compiler) because I won't be able to create a shared file among the entry points with CommonsChunkPlugin anymore</p>