首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >带LiveReload的表不工作

带LiveReload的表不工作
EN

Stack Overflow用户
提问于 2013-11-21 11:58:08
回答 5查看 18.3K关注 0票数 14

我不能让LiveReload和Grunt一起工作。我用的是咕噜-表。当Grunt正在监视指定的文件时,浏览器中没有重新加载任何内容。所以我会看看:

代码语言:javascript
运行
复制
Running "watch" task
Completed in 0.203s at Thu Nov 21 2013 00:59:59 GMT-0500 (EST) - Waiting...
OK
>> File "views/index.html" changed.

但是浏览器窗口不更新。我使用的是LiveReload 2.0.9。对如何让它运行有什么建议吗?

Gruntfile.js

代码语言:javascript
运行
复制
module.exports = function(grunt) {

  'use strict';

  grunt.initConfig({
    express: {
      dev: {
        options: {
          script: './app.js'
        }
      }
    },
    watch: {
      tasks:  [ 'express:dev' ],
      options: {
        livereload: true,
        nospawn: true
      },
      files: [
        './views/index.html',
        './preprocessing/css/style.scss'
      ]
    }
  });

  grunt.loadNpmTasks('grunt-express-server');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('default', [ 'express:dev', 'watch' ]);
};
EN

Stack Overflow用户

发布于 2015-01-26 02:15:00

我知道这个问题更老了,但是我从另一个网站得到了这个信息,它似乎可以解决这个问题,因为我也遇到了同样的问题,本质上添加了keepAlive:true to options对象将在这里工作的代码

代码语言:javascript
运行
复制
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
develop: {
  server: {
    file: 'bin/www'
  }
},
watch: {
  options: {
    nospawn: true,
    livereload: reloadPort
  },
  server: {
    files: [
      'bin/www',
      'app.js',
      'routes/*.js'
    ],
    tasks: ['develop', 'delayed-livereload']
  },
  js: {
    files: ['public/js/*.js'],
    options: {
      livereload: reloadPort,
      keepAlive:true
    }
  },
  css: {
    files: [
      'public/css/*.css'
    ],
    options: {
      livereload: reloadPort,
        keepAlive:true
    }
  },
  views: {
    files: ['views/*.ejs'],
    options: {
      livereload: reloadPort,
        keepAlive:true
    }
  }
}

});

票数 -1
EN
查看全部 5 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20120412

复制
相关文章

相似问题

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