【问题标题】:Need to Perform a Grunt Watch Forever需要永远执行 Grunt Watch
【发布时间】:2014-01-09 00:11:07
【问题描述】:

我是 Node.js 和 Grunt 的新手...我正在尝试在 Windows 服务器上使用 Node.js 和 Grunt 来查看我的 main.less 文件并进行标准编译和连接。我可以在命令提示符打开时执行此操作,但我需要在未登录到服务器的情况下将其作为守护程序运行,因为 .less 文件是从位于云中的 CMS 部署的。

我在 Grunt-Forever 中找到了有前途的文档,但它需要您指向一个应用程序,而我只想执行 grunt watch 任务。

9 个月前有人问过类似的问题,但没有人给出答案: Grunt.js Watch Forever

我从命令行尝试了这个:

FWIW,你可以永远做 /usr/local/bin/grunt --base 。 watch 与 grunt watch atm 一起使用。

但是,我遇到了错误。

这是我的 gruntfile:

module.exports = function(grunt) {

  grunt.registerTask('watch', [ 'watch' ]);

  grunt.initConfig({
    concat: {
      js: {
        src: [
          'js/global.js','js/googlemap.js'
        ],
        dest: 'js/main.min.js'
      },
    },
    uglify: {
      options: {
        mangle: false
      },
      js: {
        files: {
          'js/main.min.js': ['js/main.min.js']
        }
      }
    },
    less: {
      style: {
        files: {
          "css/style.css": "less/main.less"
        }
      }
    },
    watch: {
      js: {
        files: ['js/global.js','js/googlemap.js'],
        tasks: ['concat:js', 'uglify:js']
      },
      css: {
        files: ['less/*.less'],
        tasks: ['less:style']
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');

};

非常感谢任何帮助!

【问题讨论】:

  • 您需要指定错误是什么。

标签: gruntjs daemon watch


【解决方案1】:

使用node调用grunt,使用PM2运行管理node。

【讨论】:

    【解决方案2】:

    尝试使用nohup 运行grunt watch 任务。由于您提到了“Windows 服务器”,您可以查看有关nohup equivalent in Windows 的答案。然后,即使您退出服务器,您也会运行 grunt 任务。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-16
      • 1970-01-01
      • 1970-01-01
      • 2013-12-08
      相关资源
      最近更新 更多