External Pipeline: How to process SASS, JS in a .tmp directory?

Hello!

I’m in the process of implementing a solution where we have multiple source folders, as we have multiple APIs (SOAP, REST) between multiple groups. We wish to have a single common assets directory with images, SCSS and JS common to all the sites, as well as a common GRUNT task management system.

I’ve already got the config.rb set to enable Middleman to process different source directories from the command line:
set: source, 'source_' + ENV['project'] || 'source'
which we trigger using:
set project=<<PROJECT _ACRONYM>> & bundle exec middleman

All good.

What I’m struggling with is the lack of solid explanations or examples of how the external pipeline works. I’ve been struggling to get my grunt tasks to play along nicely with Middleman, or to have Middleman stop trying to process my stylesheets and JS for me, and let my GRUNT tasks take care of that. I’ve seen a few videos and examples of how folks have used GULP to do it, and considering how similar the two task managers are I figured I’d be able to use the GULP examples. However, where things seem to go wrong is in working within the .tmp directory – I copy my SCSS files into the .tmp directory defined by my :external_pipeline, process them, and allow Middleman to use the resulting .css files for the build, but it then tries to process them further, errors out, and only copies over the css.map files.

My pipeline code in the config.rb:

# External Pipeline for Grunt
  activate :external_pipeline,
    name: :grunt,
    command: build? ? "cd grunt/ && grunt build --project=" + ENV['project'] : "cd grunt/ && grunt dev --project=" + ENV['project'],
    source: ".tmp",
    latency: 2

# Assets
set :css_dir, 'stylesheets'
set :js_dir, 'javascripts'
set :images_dir, 'images'
set :fonts_dir, 'fonts'

I have tried disabling :sprockets, and completely removing the gem middleman-sprockets, and I’ve commented out the activate :minify_css and :minify_js, and telling Middleman to ignore 'stylesheets/*.scss'. However, Middleman continues to try to process stylesheets, etc. rather than just copying the final code back into the build folder as I would expect it to if all of that was commented out.

After looking at NathanBowers’ Gulp repository, it occurred to me that maybe I’m pointing to my directories incorrectly and processing wrong? I saw that in his config.rb he’s actually pointing Middleman to folders in his dist directory, and telling middleman to ignore his source files. Then in Gulp, he’s processing stuff into that dist directory… Is that the way to do it?

Basically, the documentation briefly says something about external_pipelines being useful, gives a couple of examples, but doesn’t really get into what the mechanics are, which has left me doing a lot of trial and error. Can some more information please be given?