module.exports = function(grunt) {

	// Project configuration.
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		banner: 
			'/*! <%= pkg.name %>.js v<%= pkg.version %>\n' +
			' *  http://<%= pkg.name %>.com/\n' +
			' *\n' +
			' *  <%= pkg.description %>\n' +
			' *  Copyright <%= grunt.template.today("yyyy") %> Paprika Patterns\n' +
			' *\n' +
			' *  Date: <%= grunt.template.today("dd-mm-yyyy") %>\n' +
			' */\n\n',
		jshint: {
			all: [ 'Gruntfile.js', '_/scripts/src/*.js' ],
		},
		uglify: {
			options: {
				banner: '<%= banner %>'
			},
			dev: {
				options: {
					mangle: false,
					compress: false,
					preserveComments: 'all',
					beautify: {
						beautify: true,
						width: 80
					}
				},
				files: {
					'_/scripts/<%= pkg.name %>.js': [
						'_/scripts/vendor/jquery/jquery.js',
						'_/scripts/src/main.js'
					]
				},
			},
			dist: {
				options: {
					mangle: true,
					compress: true
				},
				files: {
					'_/scripts/<%= pkg.name %>.js': [
						'_/scripts/vendor/jquery/jquery.min.js',
						'_/scripts/src/main.js'
					],
					'_/scripts/<%= pkg.name %>-legacy.js': [
						'_/scripts/vendor/respond/dest/respond.min.js',
						'_/scripts/vendor/html5shiv/dist/html5shiv.js',
					]
				},
			},
			tasks: ['notify:uglify']
		},
		compass: {
			options: {
				sassDir: '_/sass',
				cssDir: '.'
			},
			dev: {
				options: {
					environment: 'development',
					outputStyle: 'expanded'
				}
			},
			dist: {
				options: {
					environment: 'production',
					outputStyle: 'compressed'
				}
			},
			tasks: ['notify:compass']
		},
		grunticon: {
			options: {
				src: "_/images/icons-src/",
				dest: "_/images/icons/",
				svgo: true,
				pngcrush: true,
				colors: {
					yellow: '#ffb63a',
					grey: '5a5a5a',
				},
			},
			tasks: ['notify:images'],
		},
		watch: {
			php: {
				files: [
					'*.php',
					'**/*.php'
				],
				options: {
					livereload: true,
				}
			},
			images: {
				files: [
					'_/images/icons-src'
					],
				options: {
					livereload: true,
				},
				tasks: ['grunticon', 'compass:dev', 'notify:images'],
			},
			css: {
				files: [
					'_/sass/**/*',
					'_/sass/*',
				],
				options: {
					livereload: true,
				},
				tasks: ['compass:dev', 'notify:sass'],
			},
			js: {
				files: [
					'_/scripts/src/*.js',
					'Gruntfile.js'
				],
				options: {
					livereload: true,
				},
				tasks: ['uglify:dev', 'jshint', 'notify:js'],
			}
		},
		notify: {
			sass: {
				options: {
					title: 'Compass',
					message: 'Done!'
				}
			},
			js: {
				options: {
					title: 'Uglify + JSHint',
					message: 'Done!'
				}
			},
			images: {
				options: {
					title: 'Grunticon',
					message: 'Done!'
				}
			},
			build: {
				options: {
					message: 'Build is ready!'
				}
			}
		}
	});

	// Load the Grunt plugins.
	grunt.loadNpmTasks('grunt-contrib-compass');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-grunticon');
	grunt.loadNpmTasks('grunt-notify');

	// Register the tasks.
	grunt.registerTask('build', [
		'jshint',
		'uglify:dist',
		'compass:dist',
		'notify:build'
	]);
	grunt.registerTask('default', [
		'jshint',
		'uglify:dev',
		'grunticon',
		'compass:dev',
		'watch'
	]);
};