grunt搭建静态服务器(简陋版)

来源:互联网 发布:淘宝运营工资大概多少 编辑:程序博客网 时间:2024/05/24 07:26

需要watch和connect


其中要注意,connect在grunt运行结束,任务就完成了,所以需要借助watch


贴个gruntfile.js的配置

module.exports = function(grunt) {    // 项目配置    grunt.initConfig({        watch: {            options: {                livereload: '<%= connect.options.livereload %>'            },            files: ['*.html', "*.js", "*.json", "*/*.js"],            tasks: ['connect']        },        connect: {            options: {                livereload: 35729,                port: 9000,                open: true                // ,                // base: 'www-root'            },            server: {}        }    });    grunt.loadNpmTasks('grunt-contrib-watch');    grunt.loadNpmTasks('grunt-contrib-connect');    // 默认任务    grunt.registerTask('default', function(target) {        console.log("--BEGIN--");        grunt.task.run(['connect', 'watch']);    });}


0 0
原创粉丝点击