javascript - gruntfile.js - grunt.registerTask

标签 javascript task gruntjs runner

不确定我这样做是否正确......

module.exports = function(grunt) {
grunt.initConfig({
    pkg: grunt.file.readJSON('package.json') ,
    connect: {
        server: {
            options: {
                port: 8001 ,
                hostname: 'localhost' ,
                base: 'www-root/app/public' ,
                keepalive: true
            }
        }
    } ,
    jade: {
        files: {
            src: 'app/components/jade/index.jade' ,
            dest: 'app/public/index.html' 
        }
    } ,
    compass: {
        options: {
            config: 'config.rb'
        }
    } ,
    watch: {
        css: {
            files: '**/*.sass' ,
            tasks: ['sass'] ,
            options: {
                livereload: true
            }
        } ,
        jade: {
            files: 'app/components/**/*.jade' ,
            tasks: ['jade'] ,
            options: {
                livereload: true
            }
        }
    } 
});

grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jade');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-watch');

grunt.registerTask('default', ['connect', 'jade', 'compass', 'watch']); 
}   

每次我运行 grunt 时,它只向我显示连接任务,而不会发生任何其他情况,例如,当我更改 index.jade 文件时...是我按顺序组织任务的方式有问题还是应该添加异步运行任务的东西?

不知道该怎么办..谢谢!

最佳答案

Grunt Connect Documentation

keepalive: Keep the server alive indefinitely. Note that if this option is enabled, any tasks specified after this task will never run.

因此,您需要对“默认”分配中的任务列表重新排序:

grunt.registerTask('default', ['jade', 'compass', 'connect']);

或者类似的东西。希望有帮助;)

关于javascript - gruntfile.js - grunt.registerTask,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17148435/

相关文章:

javascript - 如果 async 属性用于加载 <head> 中的非阻塞 &lt;script&gt; ,它们是否保证在 body.readyState == 'loaded' 之前加载

java - 重定向其他 Jsp JavaScript

javascript - 按钮无法触发 jquery ui 中的幻灯片

ios - Swift XCode 使用任务从网站提取数据,但我无法将数据获取到其他函数中以使用 TableView 显示它

c# - LINQ 选择语句。匿名方法返回异常

ios - 如何修复链接器错误 "Undefined symbols for architecture i386 from: "_current_task""?

javascript - 使用 grunt 进行 Angular 缩小会导致 'Failed to instantiate module' 错误

c# - 如何在javascript中获取动态控件的id

javascript - 在 grunt-php2html 之后编辑 js 文件的 src 字符串

twitter-bootstrap - grunt-contrib-sass 不编译 css 文件