1

Here's my gulpfile.coffee:

# Dependencies
gulp           = require "gulp"
browserSync    = require "browser-sync"
minimist       = require "minimist"



# Configuration
available_arguments =

  # Default values
  default:
    path: ''
    mode: false

  # What arguments to treat as strings
  string: [
    'path'
  ]



# Preparation
args = minimist process.argv.slice(2), available_arguments



# Start BrowserSync
gulp.task "browser-sync", ->
  browserSync
    open:      args.path?
    startPath: args.path
    ghostMode: args.ghost
    server:
      baseDir: "./"


# Use default task to launch BrowserSync and watch JS files
gulp.task "default", ["browser-sync"], ->

  # add browserSync.reload to the tasks array to make
  # all browsers reload after tasks are complete.
  gulp.watch "*.html", browserSync.reload

It uses BrowserSync to watch for some files and reload the browser.

It is currently designed to work with static files.

I have started using a static site generator, Middleman. Middleman runs a development webserver that renders a generated web page from sources.

I'm capable of modifying the above Gulpfile so that BrowserSync proxies to Middleman rather than serves static files.

What i struggle to figure out is how to have Gulp start Middleman in background.

Requirements:

  • Middleman should be started in background before gulp.watch (the last line).
  • Middleman should run in parallel with Gulp. I. e. Gulp should not wait for Middleman to finish.
  • Middleman should print to the terminal (both normal messages and errors).
  • Middleman should be terminated when gulp watch terminates.
  • Gulp should be terminated when Middleman terminates, so that i can restart Middleman after fixing the problem that caused it to terminate.

The command to run Middleman is bundle exec middleman server.

Andrey Mikhaylov - lolmaus
  • 23,107
  • 6
  • 84
  • 133
  • I'm not sure if it does what you ask (no documentation), but try: https://github.com/MisumiRize/gulp-middleman – fregante Nov 22 '14 at 18:25
  • @bfred.it It's not published on npm and it seems abandoned. – Andrey Mikhaylov - lolmaus Nov 22 '14 at 19:19
  • You can install it with npm even [if it's not published](http://stackoverflow.com/questions/10386310/how-to-install-a-private-npm-module-without-my-own-registry). Even if it's abandoned, if it works now it's still a better starting point than nothing at all. – fregante Nov 22 '14 at 20:02

0 Answers0