/* global require: false */
var specHtmlExp = /\.spec\.html$/;
/**
  This file is used to configure the [grunt](http://gruntjs.com/) tasks
  aimed to generate the web frontend of the camunda BPM platform.
  @author Valentin Vago <valentin.vago@camunda.com>
  @author Sebastian Stamm  <sebastian.stamm@camunda.com>
 */

module.exports = function(grunt) {
  'use strict';
  require('load-grunt-tasks')(grunt);
  var commons = require('./index');

  var pkg = require('./package.json');

  var config = pkg.gruntConfig || {};

  config.grunt = grunt;
  config.pkg = pkg;

  grunt.initConfig({
    protractor: {
      widgets: {   // Grunt requires at least one target to run so you can simply put 'all: {}' here too.
        options: {
          configFile: 'conf.js',
          seleniumAddress: 'http://localhost:4444/wd/hub',
        },
      },
    },

    connect: {
      options: {
        port: pkg.gruntConfig.connectPort
      },
      widgetTests: {
        options: {
          middleware: function (connect, options, middlewares) {
            middlewares.unshift(function (req, res, next) {
              if (req.url === '/test-conf.json') {
                res.setHeader('Content-Type', 'application/json');
                return res.end(JSON.stringify(commons.requirejs({pathPrefix: ''})));
              }
              next();
            });
            return middlewares;
          },
          base: [
            '.'
          ]
        }
      }
    },

    less: {
      widgets: {
        files: {
          'styles.css': 'resources/less/styles.less'
        }
      }
    }
  });

  grunt.registerTask('default', ['less:widgets', 'connect:widgetTests', 'protractor:widgets']);
};

@@ -919,16 +919,68 @@
 nectPort
+,%0A        livereload: pkg.gruntConfig.livereloadPort
 %0A      %7D
@@ -1542,98 +1542,688 @@
     
-widgets: %7B%0A        files: %7B%0A          'styles.css': 'resources/less/styles.less'%0A        %7D
+options: %7B%0A        dumpLineNumbers: 'comments',%0A        compress: false,%0A        sourceMap: false%0A      %7D,%0A%0A      styles: %7B%0A        files: %7B%0A          'styles.css': 'resources/less/styles.less',%0A          'test-styles.css': 'resources/less/test-styles.less'%0A        %7D%0A      %7D%0A    %7D,%0A%0A    watch: %7B%0A      options: %7B%0A        livereload: false,%0A      %7D,%0A%0A      styles: %7B%0A        files: %5B%0A          'lib/**/*.less',%0A          'resources/less/**/*.less'%0A        %5D,%0A        tasks: %5B'less'%5D%0A      %7D,%0A%0A      served: %7B%0A        options: %7B%0A          livereload: pkg.gruntConfig.livereloadPort%0A        %7D,%0A        files: %5B%0A          '*.css',%0A          '**/*.spec.*'%0A        %5D,%0A        tasks: %5B%5D
 %0A   

add grunt setup for styles dev