I wonder if it is possible with gulp-connect to serve some files from a different directory. Something like:
http://localhost:8080/index.html => root: '/root/app'
but
http://localhost:8008/js/main.js => from '/root/js/' not from 'root/app/js'
http://localhost:8008/css/main.css => from '/root/css/' not from 'root/app/css/'
You can pass a middleware function to
gulp-connectthat allows you to modify the request object and therefore rewrite request URLs:In the above any path that starts with
/js/or/css/will be passed through unchanged. Since our base folder isrootthat means a path like/js/main.jswill resolve toroot/js/main.js.All other paths will be prepended with
/app, meaning a path like/index.htmlwill transparently resolve toroot/app/index.html.Instead of using custom logic as I did above, you can also use something like
http-rewrite-middleware, which allows you to specify nginx-inspired rewrite expressions: