首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用nginx和本地tomcat设置grunt实时加载任务

问如何使用nginx和本地tomcat设置grunt实时加载任务
EN

Stack Overflow用户
提问于 2016-02-01 23:42:15
回答 1查看 1.5K关注 0票数 4

我习惯于在本地运行一个小型节点服务器并对远程REST API进行服务调用的开发环境。我现在所处的环境中,所有内容都是本地的。有一个运行REST API的本地tomcat实例,nginx用于将来自我的angular应用程序的调用路由到tomcat服务器。我遇到的问题是运行我的grunt服务器任务-它启动了一个运行在9000端口上的连接服务器;Live reload功能不可用,因为nginx正在侦听端口80,所以要查看更改,我必须访问localhost/xyz。将nginx.server.listen端口更改为端口9000也不起作用。

代码语言:javascript
复制
#user  nobody;
worker_processes  1;

error_log  logs/error.log;

events {
    worker_connections  1024;
}

http {
  include       mime.types;
  default_type  application/octet-stream;
  sendfile        on;
  keepalive_timeout  65;

  server {
        listen 80;
        root /Users/me/dev/angular-project/app;  //this looks at my angular app

        index index.html index.htm;
        server_name localhost;
        location / {
           try_files $uri /index.html?v=100515130;

        }
        location /services1 {
                proxy_pass      http://localhost:8080/services1; //this is one of my services call addresses
                proxy_set_header Host localhost;
        }

        location /services2 {
                proxy_pass      http://localhost:8080/services2;  //this is another service call address
                proxy_set_header Host localhost;
        }

}

include servers/*;

}

我希望能够做的是非常标准的事情--查看我的.scss和es6文件并在更改时编译,然后在更改后热重新加载浏览器。下面是我的gruntfile中的连接过程:

代码语言:javascript
复制
connect: {
  options: {
    port: 9001,
    // Change this to '0.0.0.0' to access the server from outside.
    //hostname: 'localhost'
      hostname: '0.0.0.0'
  },
  livereload: {
    options: {
      middleware: function (connect) {
        return [
         modRewrite([
                    '^[^\\.]*$ /index.html [L]'
                  ]),                
          lrSnippet,
          mountFolder(connect, '.tmp'),
          mountFolder(connect, yeomanConfig.app)
        ];
      }
    }
  },

我不熟悉nginx和tomcat,但对节点构建工具相当熟悉;吞吞吐吐,但这是我继承的¯\_(ツ)_/‘

我需要在我的nginx设置中改变一些东西来实现这一点吗,或者在我的grunt设置中,或者两者都需要改变?

EN

回答 1

Stack Overflow用户

发布于 2016-03-10 15:37:56

我看不到options.livereload

代码语言:javascript
复制
connect: {
  options: {
    port: 9001,
    // Change this to '0.0.0.0' to access the server from outside.
    //hostname: 'localhost'
      hostname: '0.0.0.0'
      livereload: 35729
  },
  livereload: {
    options: {
      livereload: true 
      middleware: function (connect) {
        return [
          modRewrite([
            '^[^\\.]*$ /index.html [L]'
          ]),                
          lrSnippet,
          mountFolder(connect, '.tmp'),
          mountFolder(connect, yeomanConfig.app)
        ];
      }
    }
  },
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35134492

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档