Gulp代理 - 中间件:如何设置?

时间:2015-04-25 09:56:39

标签: ruby-on-rails gulp

我试图在我的前端应用程序和后端应用程序之间建立一个桥梁,而Gulp文档对此非常不满意。 我安装了代理中间件。

项目的结构是:

| Myproject
   | BackEnd App/ 
   | BackEnd config/
   | BackEnd folders/ ....
   | front/
      | app/
      | dist/
      gulpfile.js
      | other frontend folders/ here ...

这看起来很常见。

所以在我的Gulpfile中我有:

var proxy = require('proxy-middleware');
...
gulp.task('connect', ['styles', 'fonts'], function () {
  var serveStatic = require('serve-static');
  var serveIndex = require('serve-index');
  var app = require('connect')()
    .use(require('connect-livereload')({port: 35729}))
    .use(serveStatic('.tmp'))
    .use(serveStatic('app'))
    .use('/bower_components', serveStatic('bower_components'))
    .use(serveIndex('app'))
        .use('/', proxy(url.parse('http://localhost:3000')));

  require('http').createServer(app)
    .listen(9000)
    .on('listening', function () {
      console.log('Started connect web server on http://localhost:9000');
    });
});

 gulp.task('serve', ['rails', 'connect', 'watch'], function () {
   require('opn')('http://localhost:9000');
 });

我知道这看起来很奇怪(/重定向到localhost:3000),它可能会产生500个我的资产(css和js)

有没有人深入研究并找到解决方案或doc / tuto?

0 个答案:

没有答案
相关问题