marcus-h
11/18/2013 - 6:51 PM

Gruntfile with support for less to css, livereload and server. Depends on: grunt-contrib-less grunt-contrib-watch and grunt-contrib-connect

Gruntfile with support for less to css, livereload and server. Depends on: grunt-contrib-less grunt-contrib-watch and grunt-contrib-connect

/* global module:true 
 * 
 * Gruntfile.js
 * npm install -g grunt-cli
 * npm install grunt-contrib-less grunt-contrib-watch grunt-contrib-connect --save-dev
 */
module.exports = function(grunt) {
  'use strict';
  // Default port
  var LIVERELOAD_PORT = 35729;

  grunt.initConfig({
    connect: {
      server: {
        options: {
          base: 'app',
          // This will inject live reload script into the html
          livereload: LIVERELOAD_PORT
        }
      }
    },
    // Less files are in app/less, output is in app/css
    less: {
      development: {
        options: {
          paths: ["./app/less"],
          yuicompress: false
        },
        files: {
        "./app/css/styles.css": "./app/less/styles.less"
        }
      }
    },
  
    watch: {
      options: {
        livereload: LIVERELOAD_PORT
      },
      files: "./app/less/*.less",
      tasks: ["less"]
    }
  });

  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-connect');

  // Run grunt server to get going
  grunt.registerTask('server', [
    'connect',
    'watch'
  ]);
};