Grunt表达livereload和代理不起作用?

时间:2015-04-22 09:09:33

标签: express proxy livereload grunt-connect-proxy

我想通过livereload从grunt启动一个Web服务器,并且代理Rest调用服务器。    这是我的Gruntfile.js:

 var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;

module.exports = function(grunt) {
    // Load Grunt tasks declared in the package.json file
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
    // 1. Toutes les configurations vont ici:
    grunt.initConfig({
        pkg : grunt.file.readJSON('package.json'),
    watch: {
        all: {
            files: 'webapp/*',
            options: {
                livereload: true,
             }
        },
    },


    express : {
        all : {
            options : {
                bases : 'webapp',
                port : 3000,
                debug:true,
                hostname : "0.0.0.0",
                livereload : true,
                middleware: function (connect, options) {
                    return [proxySnippet];
                }
            },
        }
    },      

    connect: {
        proxies: [{
                context: '/sis.cata/rest',
                host: 'localhost',
                port: 8080,
        https: false,
        changeOrigin: false,
        xforward: false
                }],
    },

    grunt.registerTask('develop', ['configureProxies:connect', 'express:all', 'watch' ]);};

提供静态文件,但不会代理和阻止对REST服务的调用。

有什么想法吗?

我已经看到使用connect和proxy的解决方案工作正常但从未使用livereload。

非常感谢。

0 个答案:

没有答案
相关问题