How to proxy JS files to different folders?

My goal is to automatically create several folders including all necessary files to display a webpage on its own, based on a loop of folder names (simplified example).

HTML and CSS get rendered fine with the approach listed at the bottom (with layouts + templates and css imports combined together).

However somehow the JS does not get compiled properly with this proxy approach - basically it doesn’t include the other JS files referenced within the all.js file (//= require "_somelibrary").
JS compilation works fine without proxying, but I’m ignoring the non-proxied files on purpose. It also works fine if I use the inline JS plugin, but I want the JS file to be separated.

Is there any trick to make it compile the JS files using proxy?

Loop in config.rb:

["foo", "bar"].each do |folder_name|
  proxy "/#{folder_name}/index.html", "/index.html"
  proxy "/#{folder_name}/stylesheets/styles.css", "/stylesheets.css"
  proxy "/#{folder_name}/javascripts/all.js", "/javascripts/all.js"
end

ignore "index.html"
ignore "javascripts/all.js"
ignore "stylesheets/styles.css"

Folder Structure (with intended build structure):

====
- source
  - javascripts
    - _somelibrary.js
    - all.js
  - stylesheets
    - _somecss.scss
    - all.scss
  - layouts
    - layout.html.haml
  - index.html.haml
- build
  - bar
    - javascripts
      - all.js
    - stylesheets
      - styles.css
    - index.html
  - foo
    - javascripts
      - all.js
    - stylesheets
      - styles.css
    - index.html
- config.rb
====

I’m using Middleman 3.4. Let me know if you need any additional context or source code to help me.

Still haven’t resolved that issue - maybe someone of the Pro’s can help? :open_mouth: