0

我已经盯着我的 grunt 配置看了几个小时,似乎无法启动和运行。

我的文件正在我期望的地方构建(基本上就在它们所在的地方,除了车把),但我真的很难让自动刷新服务器启动并运行。无法完全启动和运行。

如果有人能指出我正确的方向,那将是一个巨大的帮助!

module.exports = function(grunt) {

    grunt.initConfig({

        pkg: grunt.file.readJSON('package.json'),

        sass: {
            files: {
                'assets/css/style.css' : 'assets/css/*.scss'
            }       
        },
        assemble: {
            options: {
                flatten: true,
                assets: 'assets',
                layout: 'templates/layouts/main.hbs'
            },
            pages: {
                src: ['templates/*.hbs'],
                dest: '.'
            }
        },
        watch: {
            all: {
                files: '**/*.hbs',
                tasks: ['assemble'],
                options: {
                    livereload: true,
                }
            },
            css: {
                files: 'assets/css/*.scss',
                tasks: ['sass']
            },
            scripts: {
                files: 'assets/js/*.js',
            },
            livereload: {
                options : { livereload: true },
                files: ['/']
            }
        },
        connect: {
            options: {
                port: 9001,
                livereload: 35729,
                hostname: '0.0.0.0',
                keepalive: true,
                open: true
            }
        }
    });

    grunt.loadNpmTasks('assemble');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-open');

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

1 回答 1

0

这是我在朋友的帮助下设法完成的工作 - 使用了一些过时的模块。希望它对某人有用!

module.exports = 功能(咕噜声){

grunt.initConfig({
    sass: {
        all: {
            files: {
                'assets/css/style.css' : 'assets/css/main.scss'
            }   
        }
    },
    assemble: {
        options: {
            flatten: true,
            assets: 'assets',
            layout: 'templates/layouts/main.hbs'
        },
        pages: {
            src: ['templates/*.hbs'],
            dest: '.'
        }
    },
    watch: {
        assemble: {
            files: 'templates/**/*.hbs',
            tasks: ['assemble']
        },
        sass: {
            files: 'assets/css/*.scss',
            tasks: ['sass']
        },
        css: {
            files:['assets/css/*.css']
        },
        scripts: {
            files: 'assets/js/*.js',
        },
        livereload: {
            options : { livereload: true },
            files: ['*.html','assets/css/*.css','assets/js/*.js']
        }
    },
    connect: {
        options: {
            port: 9001,
            livereload: true,
            hostname: '0.0.0.0'
        },
        livereload: {
            options: {
                open: true,
                base: ['.']
            }
        }
    }
});

grunt.loadNpmTasks('assemble');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');

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

}

于 2014-07-22T08:30:36.363 回答