Tag: grunt contrib connect

什么是中间件Yeomanfunction实现的目的?

我是grunt-contrib-connect中的新手,并且遇到了这个跟随middleware函数Yoeman的实现 – middleware: function(connect, options, middlewares) { return [ proxySnippet, connect.static('.tmp'), connect().use('/bower_components', connect.static('./bower_components')), connect.static(config.app) ]; } 这个实现的目的是什么?

麻烦运行使用grunt静态服务器的Qunittesting

通过networking浏览器运行testing工作正常,但使用grunt给我错误。 我很难理解我在这里做错了什么。 grunt tests失败 $ grunt tests Running "jsonlint:sample" (jsonlint) task >> 4 files lint free. Running "jshint:all" (jshint) task >> 4 files lint free. Running "connect:server" (connect) task Started connect web server on http://localhost:5000 Running "qunit:all" (qunit) task Testing http://localhost:5000/tests/tests.html F >> Settings.json tests – Fetching settings file >> Message: InvalidStateError: DOM Exception 11: […]

Grunt-contrib-watch用grunt-contrib-connect

不幸的是, grunt-contrib-watch和grunt-contrib-connect似乎并不好。 在grunt-contrib-connect 自述文件中说: 请注意,此服务器只在运行grunt时才运行。 一旦咕噜的任务完成,Web服务器停止。 这种行为可以通过Keepalive选项来改变,并且可以通过运行像grunt connect :: keepalive这样的任务来启用ad-hoc。 精细。 但是如果我想与连接服务器一起运行我的监视任务呢? 像这样: connect: { server: { options: { port: 8000, hostname: 'localhost', keepalive: true } } }, watch: { options: { livereload: true }, files: ['**'], tasks: ['connect'], } 这里, connect任务在文件改变时运行。 如果我将connect的keepalive选项设置为true,那么grunt-contrib-watch会停止监视,因为它在技术上还没有完成任务。 如果我伪造keepalive选项,那么连接服务器在完成任务后就会死亡。 是的,我可以运行命令… $ grunt connect $ grunt watch …在单独的shell中,但没有办法用一个命令来运行它们吗?

如何使用VSCode和grunt-contrib-connect连接到节点

我无法使用Visual Studio代码来debugging我的节点应用程序。 我的.vscode/launch.json如下所示: { "version": "0.2.0", "configurations": [{ "name": "Attach", "type": "node", "request": "attach", "port": 9001 }] } 我使用grunt-contrib-connect来启动我的Web服务器。 我的连接任务被定义为我的gruntfile.js像这样: connect: { server: { options: { debug:true, port: 9001, base: '.', livereload: true, }, }, }, 以上任务成功启动Web服务器后,我尝试从VSCode附加,但除了一些UI闪烁,似乎没有任何事情发生。 没有断点被击中。 我阅读了VS Codedebugging文档 ,特别是将VS代码附加到节点部分,这就是为什么我在我的连接任务中添加了debug:true原因。 但是,这似乎并没有解决任何问题。

如何在防火墙后面configurationgrunt-connect-proxy?

我正在尝试设置grunt-contrib-connect为我的XHR调用提供一个代理。 我发现grunt-connect-proxy似乎是我想要的。 但是我在企业防火墙的后面,不允许来自node的请求通过。 我得到的错误是: An error has occurred: {"code":"ETIMEDOUT","errno":"ETIMEDOUT","syscall":"connect"} 如何设置connect任务,使其通过企业防火墙?

当主机是0.0.0.0时,grunt-connect不工作

我试图从外部访问使用grunt-contrib-connect插件创build的本地node.js开发服务器。 当我使用localhost或127.0.0.1作为hostname参数时,服务器工作(在本地)。 但是,当我将参数更改为*或0.0.0.0以允许外部访问(如文档中指定)时,我无法在本地或外部访问服务器; 这是我在Chrome中得到的错误: 我已经尝试禁用我的防火墙,我可以看到数据包从我的手机进入正确的端口(我用来尝试从外部访问我的本地服务器)。 任何想法为什么它不能使用*或0.0.0.0作为hostname ?

转发咕噜连接到不同的url

我使用grunt连接livereload为我的开发环境。 我想能够调用服务器下的生产API。 要做到这一点,我需要指挥任何来电 http://localhost:9000/server 至 http://www.production-server.com/server 这对我有好处,因为有时我想在开发模式下对生产服务器进行testing。 这是我目前的连接configuration(由Yeoman生成): connect: { options: { port: 9000, // Change this to '0.0.0.0' to access the server from outside. hostname: 'localhost', livereload: 35729 }, livereload: { options: { open: true, middleware: function(connect, options, middlewares) { return [ connect.static('.tmp'), connect().use( '/bower_components', connect.static('./bower_components') ), connect.static(appConfig.app) ]; } } }, test: { […]

如何使用Grunt或Node服务器基于User-Agent(移动和桌面)redirect请求/代理?

我正在使用Grunt及其代理库grunt-connect-proxy 。 我有两台服务器设置为我的网站的桌面和移动版本(两者都有单独的资产等,因此分离)。 这两个网站都托pipe在0.0.0.0,但在不同的端口(9000和10000)。 我怎么能代理请求到两个不同的服务器基于User-Agent头(这将告诉我,如果它是一个移动或桌面用户)? NodeJS中有另一种解决scheme可以使用吗?

Grunt-contrib-connect:如何在指定的浏览器中启动服务器

我对于凉亭 / 咕噜 / 野人环境来说是相当新颖的。 我试图自定义由默认的yeoman Webapp生成器生成的应用程序。 基本上,当我启动grunt serve ,默认浏览器将会启动,打开grunt服务器提供的URL。 我想指定在哪个浏览器应该打开Web应用程序,但我没有运气。 这些是gruntfile中连接任务(使用grunt-contrib-connect )的默认选项: connect: { options: { port: 9000, open: true, livereload: 35729, // Change this to '0.0.0.0' to access the server from outside hostname: 'localhost', } 我试图添加字段appName: 'Firefox'但我认为这不是我正在寻找。 我想应用程序名是用来指定如何从命令行(例如open命令)的默认浏览器,是吗? 是否有可能在grunt-contrib-connect中指定浏览器或根本不指定? 如果不是我该如何完成这个任务? 也许用grunt-open ? 谢谢

Grunt连接不以错误开始“根path必须是一个string”

我试图设置我的Gruntfile使用grunt连接npm模块。 我尝试使用grunt clean server命令启动服务器时遇到问题。 它的错误与行: Warning: root path must be a string Use –force to continue. 我真的不确定我搞错了什么configuration,可以使用另一套眼睛。 这是我的Gruntfile: /* global module, conf */ var modRewrite = require('connect-modrewrite'); var mountFolder = function(connect, dir) { return connect.static(require('path').resolve(dir)); }; module.exports = function(grunt) { grunt.initConfig({ copy: { base: { files: [ {src: "index.html", dest: "BUILD/index.html"}, {expand: true, src: "app/**", […]