Change where certain generated resources are placed
<p>I currently have two projects; one for the server-side (<a href="http://doc.akka.io/docs/akka/2.4.7/scala/http/index.html" rel="nofollow noreferrer">Akka-HTTP</a>) and one for the client-side (<a href="https://www.scala-js.org/" rel="nofollow noreferrer">ScalaJS</a>). The client-side generates the <code>.js</code> files I want to serve using the server-side. To give the server-side access to those files, I added this <code>build.sbt</code> entry in the server-side project:</p>

<pre><code>lazy val server = project.in(file("server"))
  ...
  .settings(
    (resourceGenerators in Compile) &lt;+= Def.task {
      val f1 = (fullOptJS in client).value.data
      val f1sm = f1.getParentFile / (f1.getName + ".map")
      f1 :: f1sm :: (packageMinifiedJSDependencies in client).value :: Nil
    }
  )
</code></pre>

<p>This, however, puts my <code>.js</code> and <code>.map</code> files inside the root of the <code>classes</code> folder. Since I want to serve my assets like so:</p>

<pre><code>pathPrefix("assets") {
  ...
  pathPrefix("client") {
    getFromResourceDirectory("&lt;directory where .js and .map files are placed&gt;")
  }
}
</code></pre>

<p>with emphasis on the <code>#getFromResourceDirectory</code> method, this isn't going to work with my assets inside the root of my <code>classes</code> folder. My <code>application.conf</code> is placed in the same directory as the generated files which would make that available for the whole world to see. </p>

<p>What I would like is my <code>.js</code> and <code>.map</code> files inside a sub-directory of the <code>classes</code> directory. Something like <code>client/</code> so I can use the <code>#getFromResourceDirectory</code> method like <code>getFromResourceDirectory("client")</code> and don't worry my configuration file is available to the outside world.</p>

<p>My question - <strong><em>How do I achieve this?</em></strong></p>

<p>I already tried adding:</p>

<pre><code>lazy val client = project.in(file("client"))
  ...
  .settings(inConfig(Compile)((fullOptJS :: packageMinifiedJSDependencies :: Nil)
    .map(a =&gt; (crossTarget in a) ~= (_ / "client")))
  )
</code></pre>

<p>to my client-side project which only places the generated <code>.js</code> and <code>.map</code> files in a client folder in the client-side project its <code>scala-2.11</code> folder:</p>

<p><img src="https://i.stack.imgur.com/9qPHM.png" width="300" alt="client-side target overview"></p>

<p>but the setting does not propagate to the server-side project its <code>classes</code> folder:</p>

<p><img src="https://i.stack.imgur.com/kUW1n.png" width="300" alt="server-side target overview"></p>

<h2>This is the desired situation:</h2>

<p><img src="https://i.stack.imgur.com/rbTLS.png" width="300" alt="server-side target overview desired"></p>