yumikokh
8/14/2014 - 6:17 PM

jekyll + compass + browser-sync

jekyll + compass + browser-sync

module.exports = function(grunt) {

    // All configuration goes here
    grunt.initConfig({

        jekyll: {
            build : {
                dest: '_site'
            }
        },

        // sass: {
        //     dist: {
        //         files: {
        //             'css/*.css': '_sass/*.scss'
        //         }
        //     }
        // },

        compass: {
            dist:{
                options:{
                    sassDir:'_sass',
                    cssDir:'css',
                    environment: 'production',
                    sourcemap: true
                }
            }
        },

        watch: {
            // sass: {
            //     files: ['_sass/*.scss'],
            //     tasks: ['sass']
            // },
            compass: {
                files: ['_sass/*.scss','_sass/*.sass'],
                tasks: ['compass'],
                options: {
                    interrupt: true,
                    atBegin: true
                }
            },
            jekyll: {
                files: ['*.html', 'css/*.css'],
                tasks: ['jekyll']
            }
        },

        browserSync: {
            files: {
                src : ['_site/css/*.css']
            },
            options: {
                watchTask: true,
                ghostMode: {
                    clicks: true,
                    scroll: true,
                    links: true,
                    forms: true
                },
                server: {
                    baseDir: '_site'
                }
            }
        }

    });

    // Load the plugins
    // grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-jekyll');
    grunt.loadNpmTasks('grunt-browser-sync');
    grunt.loadNpmTasks('grunt-contrib-compass');

    // Custom tasks
    // -- ビルド時にsassじゃなくてcompassでコンパイル
    grunt.registerTask('build', ['compass', 'jekyll']);
    grunt.registerTask('default', ['build', 'browserSync', 'watch']);
};