1

我们如何使用 node.js 连接中间件将某个路径映射到另一个路径?

例如,我希望我的服务器fileA在请求fileB.

(用于内部使用grunt-contrib-connect

4

1 回答 1

0

我有一个愚蠢的方法,但它是一种方法!

copy: {
    "mount-server": {
        files: [{
            expand: true,
            dot: true,
            cwd: '<%= yeoman.app %>',
            dest: './.mount-server/search/mobileqq/',
            src: [
               '**/**'
            ]
        }]
    }
}
     connect: {
        options: {
            port: 80,
            // change this to '0.0.0.0' to access the server from outside
            hostname: null
        },
        livereload: {
            options: {
                middleware: function (connect, options) {
                    return [
                        lrSnippet,
                        mountFolder(connect, '.tmp'),
                        mountFolder(connect, "./.mount-server/")
                    ];
                }
            }
        }
   }

grunt.registerTask('prepareServer', [
    "clean:mount-server",
    "copy:mount-server"
]);
grunt.registerTask('server', function (target) {
    if (target === 'dist') {
        return grunt.task.run(['build', 'open', 'connect:dist:keepalive']);
    }

    grunt.task.run([
        'concurrent:server',
        "prepareServer",
        'connect:livereload',
        'open:server',
        'watch'
    ]);
});

只需复制您的文件并制作另一个安装文件夹!

于 2014-04-03T02:56:15.373 回答