使用grunt-contrib-connect - 带添加上下文路径的打开页面URL [英] Using grunt-contrib-connect - open page URL with added context path

查看:164
本文介绍了使用grunt-contrib-connect - 带添加上下文路径的打开页面URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



  connect:{
options:{
端口:9000,
livereload:35729,
主机名:'localhost'
},
livereload:{
选项:{
open:true,
base:[
'app'
]
}
}
}

这很好 - 将我的index.html页面加载为:

  http: // localhost:9000 

然而,为了保持它与生产中的加载一致,希望它加载额外的上下文路径,如:

  http:// localhost:9000 / myappcontext / secured 

这可以通过grunt-contrib-connect简单完成吗?或者我需要添加一些其他代理/中间件?

任何人都有这种设置的简单例子吗?

解决方案

是的,您可以毫不费力地做到这一点,只需配置打开选项即可:

  connect:{
options:{
port:9000,
livereload:35729,
hostname:'localhost'
},
livereload:{
options:{
open:{
target:'http:// localhost:9000 / myappcontext / secured'
},
base:[
'app'
]
}
}
}

有关可用选项的更多信息,请参阅自述文件。


I have set up grunt connect like this:

connect: {
    options: {
        port: 9000,
        livereload: 35729,
        hostname: 'localhost'
    },
    livereload: {
        options: {
            open: true,
            base: [
                'app'
            ]
        }
    }
}

That works great - loads my index.html page as:

http://localhost:9000

However, to keep this consistent with how it will be loaded in production, I would like it to load it with additional context path added, like:

http://localhost:9000/myappcontext/secured

Can this be done simply with grunt-contrib-connect? Or do I need to add some other proxy/middleware?

Anyone got a simple example of this type of set-up?

解决方案

Yes you can do this without much trouble, just configure the open option:

connect: {
    options: {
        port: 9000,
        livereload: 35729,
        hostname: 'localhost'
    },
    livereload: {
        options: {
            open: {
                 target: 'http://localhost:9000/myappcontext/secured'
            },
            base: [
                'app'
            ]
        }
    }
}

You can consult the README for more information about the available options.

这篇关于使用grunt-contrib-connect - 带添加上下文路径的打开页面URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆