gulpgulp-connect

`gulp-connect` virtual folder


Is it possible to get gulp-connect to add a non-existent folder into a URL?

To elaborate:

My project is in /Sites/mySite, in this folder I have a gulpfile.js and I cd into this folder, run gulp and get a http server on: http://localhost:8080/.

I would like to still be able to cd into /Sites/mySite run gulp but have the url for this content accessible from http://localhost:8080/igloo.

This feels like some sort of middleware but I cannot get my head around connect/gulp-connect.


Solution

  • I have a similar setup. The root of my app is at dist/, but I also need access to node_modules/ for my source maps:

    https://www.npmjs.com/package/st

    var st = require('st')
    
    ...
    
    gulp.task('server', function() {
      connect.server({
        root: 'dist/',
        host: 'localhost',
        port: 3000,
        livereload: {
          port: 35929
        },
        middleware: function (connect, opt) {
          return [
            st({ path: 'node_modules', url: '/node_modules' })
          ];
        }
      })
    })