需要永远执行Grunt Watch

Bul*_*rog 5 daemon watch gruntjs

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

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

其他人在9个月前问了一个类似的问题,但没有人给出答案: Grunt.js永远观看

我从命令行尝试了这个:

FWIW,你可以永远做/ usr/local/bin/grunt --base.注意永远使用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');

};
Run Code Online (Sandbox Code Playgroud)

任何帮助深表感谢!

Lac*_*zar 0

尝试使用 运行grunt watch任务nohup既然您提到了“Windows 服务器”,您可以检查有关Windows 中 nohup 等效项的答案。然后,即使您注销服务器,grunt 任务也会运行。