0

鉴于此Gruntfile.coffee,我想保持shell:server任务运行并输出到 shell,同时watch检查前端资产的更改并在运行我的:compile任务时向 shell 报告。
所有这些都来自同一个grunt命令到同一个 shell。

module.exports = (grunt) ->
  grunt.initConfig
    pkg: grunt.file.readJSON('package.json')

    coffee:
      compile:
        files:
          'public/js/app.js': 'assets/js/app.coffee'

    stylus:
      compile:
        files:
          'public/css/app.css': 'assets/css/app.styl'

    watch:
      css:
        files: 'assets/**/*.styl'
        tasks: 'stylus'
      javascript:
        files: 'assets/**/*.coffee'
        tasks: 'coffee'

    shell:
      server:
        command: 'supervisor index.coffee'
        options:
          stdout: true

  grunt.loadNpmTasks('grunt-contrib-coffee')
  grunt.loadNpmTasks('grunt-contrib-stylus')
  grunt.loadNpmTasks('grunt-contrib-watch')
  grunt.loadNpmTasks('grunt-shell')

  grunt.registerTask('work', ['default', 'shell:server', 'watch'])
  grunt.registerTask('default', ['coffee', 'stylus'])

一个好处是取消supervisor支持使用 Grunt 来监视服务器更改并重新启动 Web 服务器。

4

1 回答 1

0

选项:

  1. 查看其中一项任务是否提供了一个background: true选项(例如,IIRC,grunt-karma 提供了一个选项)

  2. 查看grunt-parallel

于 2013-12-12T07:45:08.390 回答