module.exports = function(grunt) {

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

    uglify: {
      frontpage: {
        src:  'js/*.js',
        dest: '../public/js/script.js'
      }
    },

    spriteGenerator: {
      "sprite": {
        src: [
          'images/sprite/*.png'
        ],
        spritePath: 'images/sprite.png',
        stylesheetPath: 'css/sprite.styl',
        compositor:'gm',
        stylesheet: 'stylus',
        stylesheetOptions:{
          prefix:'sprite_',
          spritePath:'/image/sprite.png',
          pixelRatio:2
        },
        layout:'packed',
        layoutOptions:{
          padding:8
        },
        compositorOptions:{
          compressionLevel:9
        }
      }
    },

    stylus: {
      compile: {
        options:{
          compress:false
        },

        files: {
          "../public/css/style.raw.css":'css/style.styl'
        }
      }
    },

    csso: {
      search: {
        files: {
          '../public/css/style.css':'../public/css/style.raw.css'
        }
      }
    },

    imagemin: {
      static: {
        options: {
          optimizationLevel: 7
        },
        files: {
          '../public/image/sprite.png': 'images/sprite.png'
        }
      }
    }

  });



  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-internal');
  grunt.loadNpmTasks('grunt-contrib-uglify');

  grunt.loadNpmTasks('node-sprite-generator');
  grunt.loadNpmTasks('grunt-contrib-imagemin');

  grunt.loadNpmTasks('grunt-csso');
  grunt.loadNpmTasks('grunt-contrib-stylus');

  grunt.registerTask('css',['stylus','csso']);
  grunt.registerTask('js',['uglify']);

  grunt.registerTask('default', ['css']);
  grunt.registerTask('full',['spriteGenerator','css','imagemin','js'])
};
