0

我有两个文件:启动http服务器的app.js和由browserify编译并在html中使用的main.js

所以我有一个配置了forever、browserify和watch的Grunt。我希望在 app.js 机会上,必须重新启动 http(通过永远:重新启动),并且当 main.js 更改时,必须对构建进行浏览器化(通过 browserify)

所以,当我运行 grunt 时,永远说:start 不存在,有什么帮助吗?

$ grunt
Warning: Task "forever:server1:start" not found. Use --force to continue.

这是我的 gruntfile:

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    browserify: {
      dist: {
        files: {
          'examples/public/js/module.js': ['examples/main.js']
        }
      }
    },
    forever: {
      server1: {
        options: {
          index: 'examples/app.js',
          logDir: 'examples/logs'
        }        
      }
    },
    watch: {
      app: {
        files: ['examples/*.js', 'examples/templates/*' ],
        tasks: ['forever:server1:start']
      },
      web: {
        files: ['examples/*.js', 'examples/templates/*' ],
        tasks: ['browserify']
      },
    }
  });

  //grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-contrib-watch');

  // Default task(s).
  grunt.registerTask('default', ['browserify', 'forever:server1:start']);
  grunt.registerTask('restart', ['browserify', 'forever:server1:restart']);

};
4

1 回答 1

1

找不到任务,因为您缺少grunt.loadNpmTasks('grunt-forever')。您可能还会发现使用 nodemon 之类的东西而不是 grunt 会更成功。

于 2014-04-05T10:36:26.507 回答