module.exports = function(grunt) {

  require('load-grunt-tasks')(grunt);

  grunt.loadNpmTasks('grunt-execute');
  grunt.loadNpmTasks('grunt-contrib-clean');

  grunt.initConfig({

    clean: ["dist"],

    copy: {
      src_to_dist: {
        cwd: 'src',
        expand: true,
        src: [
          '**/*',
          '!datasource-zabbix/*.js',
          '!panel-triggers/*.js',
          '!components/*.js',
          '!module.js',
          '!**/*.scss'
        ],
        dest: 'dist/'
      },
      pluginDef: {
        expand: true,
        src: ['plugin.json'],
        dest: 'dist/',
      }
    },

    watch: {
      rebuild_all: {
        files: ['src/**/*', 'plugin.json'],
        tasks: ['default'],
        options: {spawn: false}
      },
    },

    babel: {
      options: {
        presets:  ["es2015"]
      },
      dist: {
        options: {
          sourceMap: true,
          plugins: ['transform-es2015-modules-systemjs', "transform-es2015-for-of"]
        },
        files: [{
          cwd: 'src',
          expand: true,
          src: [
            'datasource-zabbix/*.js',
            'panel-triggers/*.js',
            'components/*.js',
            'module.js',
          ],
          dest: 'dist/'
        }]
      },
      distTestNoSystemJs: {
        files: [{
          cwd: 'src',
          expand: true,
          src: ['**/*.js'],
          dest: 'dist/test'
        }]
      },
      distTestsSpecsNoSystemJs: {
        files: [{
          expand: true,
          cwd: 'specs',
          src: ['**/*.js'],
          dest: 'dist/test/specs'
        }]
      }
    },

    mochaTest: {
      test: {
        options: {
          reporter: 'spec'
        },
        src: [
          'dist/test/datasource-zabbix/specs/test-main.js',
          'dist/test/datasource-zabbix/specs/*_specs.js'
        ]
      }
    },

    sass: {
      options: {
        sourceMap: true
      },
      dist: {
        files: {
          'dist/panel-triggers/css/panel_triggers.css' : 'src/panel-triggers/sass/panel_triggers.scss',
        }
      }
    },

    jshint: {
      source: {
        files: {
          src: ['src/**/*.js'],
        }
      },
      options: {
        jshintrc: true,
        reporter: require('jshint-stylish'),
        ignores: [
          'node_modules/*',
          'dist/*',
        ]
      }
    },

    jscs: {
      src: ['src/**/*.js'],
      options: {
        config: ".jscs.json",
      },
    }

  });

  grunt.registerTask('default', [
    'clean',
    'copy:src_to_dist',
    'copy:pluginDef',
    'jshint',
    'jscs',
    'sass',
    'babel',
    'mochaTest'
  ]);
};

@@ -700,23 +700,25 @@
 asks: %5B'
-default
+watchTask
 '%5D,%0A    
@@ -2630,12 +2630,169 @@
 t'%0A  %5D);
+%0A%0A  grunt.registerTask('watchTask', %5B%0A    'clean',%0A    'copy:src_to_dist',%0A    'copy:pluginDef',%0A    'jshint',%0A    'jscs',%0A    'sass',%0A    'babel:dist'%0A  %5D);
 %0A%7D;%0A

remove tests from watch task.