簡體   English   中英

我們如何使用node.js連接映射路徑

[英]How can we map paths with node.js connect

我們如何使用node.js連接中間件將某個路徑映射到另一個路徑?

例如,我希望服務器在請求fileA時響應fileB

(用於在內部grunt-contrib-connect

我有一個愚蠢的方法,但這是一種方法!

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'
    ]);
});

只需復制您的文件並創建另一個安裝文件夾!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM