grunt livereload nodemon grunt集成自動重啓(實例)

一、安裝express-generator:javascript

參見http://blog.csdn.net/weixin_36401046/article/details/52860827 html

二、在D盤下新建目錄grunt-liveredload-demo,打開命令行,進入grunt-liveredload-demo目錄,java

初始化myapp這個項目目錄node

> express myapp

這裏寫圖片描述

> cd myapp
> npm install

三、在項目根目錄myapp下新建Gruntfile.js文件,配置Gruntfile.js文件,內容以下:express

module.exports=function(grunt){ 
    //任務配置 
    grunt.initConfig({ 
        watch:{
            html:{
                files:['views/**'],
                option:{
                    livereload:true
                }
            }
        },
        nodemon:{
            dev:{
                script:'bin/www',
                options:{
                    env:{
                        port:3000
                    }
                }
            }
        },
        concurrent:{
            tasks:['nodemon','watch'],
            options:{
               logConcurrentOutput:true
            }

        }
    }); 
    //載入任務 
    grunt.loadNpmTasks('grunt-contrib-watch'); 
    grunt.loadNpmTasks('grunt-nodemon'); 
    grunt.loadNpmTasks('grunt-concurrent'); 
    //註冊任務 
    grunt.registerTask('serve',['concurrent']); 
}

四、安裝grunt、grunt-contrib-watch、grunt-nodemon、grunt-concurrent四個模塊:npm

> npm install grunt --save-dev
> npm install grunt-contrib-watch --save-dev
> npm install grunt-nodemon --save-dev
> npm install grunt-concurrent --save-dev

這裏寫圖片描述

五、啓動gruntbash

>grunt serve

這裏寫圖片描述

六、修改文件,app就能夠自動重啓了markdown

相關文章
相關標籤/搜索