module.exports = function (grunt) {
	// Project configuration.
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),

		concat: {
			dist: {
				src: [
					'../../Resources/Private/JavaScript/bower_components/jquery/dist/jquery.js',
					'../../Resources/Private/JavaScript/bower_components/jquery-hoverintent/jquery.hoverIntent.js',
					'../../Resources/Private/JavaScript/bower_components/flexnav/js/jquery.flexnav.js',
					'../../Resources/Private/JavaScript/MailObfuscator.js',
					'../../Resources/Private/JavaScript/Main.js'
				],
				dest: '../../Resources/Public/JavaScript/Main.js'
			},
			backend: {
				src: '../../Resources/Private/JavaScript/Backend.js',
				dest: '../../Resources/Public/JavaScript/Backend.js'
			}
		},

		uglify: {
			options: {
				sourceMap: true
			},
			dist: {
				src: '../../Resources/Public/JavaScript/Main.js',
				dest: '../../Resources/Public/JavaScript/Main.min.js'
			},
			backend: {
				src: '../../Resources/Public/JavaScript/Backend.js',
				dest: '../../Resources/Public/JavaScript/Backend.min.js'
			}
		},

		compass: {
			options: {
				//force: true
			},
			dist: {
				options: {
					config: '../../Resources/Private/Styles/config.rb',
					basePath: '../../Resources/Private/Styles'
				}
			}
		},

		less: {
			theme: {
				files: {
					"../../Resources/Public/css/theme.css": "../../Resources/Public/css/less/theme.less"
				}
			}
		},

		autoprefixer: {
			options: {
				map: true,
				browsers: ['last 2 versions', 'ie 9']
			},
			dist: { src: ['../../Resources/Public/Styles/*.css', '!../../Resources/Public/Styles/*.min.css'] }
		},

		cmq: {
			dist: {
				cwd: '../../Resources/Public/Styles/',
				src: ['*.css'],
				dest: '../../Resources/Public/Styles/'
			}
		},

		cssmin: {
			minify: {
				expand: true,
				cwd: '../../Resources/Public/Styles/',
				src: ['*.css', '!*.min.css'],
				dest: '../../Resources/Public/Styles/',
				ext: '.min.css'
			}
		},

		watch: {
			scripts: {
				files: ['../../Resources/Private/JavaScript/*.js', '../../Resources/Private/JavaScript/**/*.js'],
				tasks: ['concat', 'uglify'],
				options: {
					spawn: false
				}
			},
			css: {
				files: ['../../Resources/Private/Styles/*.scss', '../../Resources/Private/Styles/**/*.scss'],
				tasks: ['compass', 'autoprefixer', 'cssmin'],
				options: {
					spawn: false,
					livereload: true
				}
			}
		}
	});

	// Load the plugin that provides the "concat" task.
	grunt.loadNpmTasks('grunt-contrib-concat');

	// Load the plugin that provides the "trim trailing spaces" task.
	grunt.loadNpmTasks('grunt-trimtrailingspaces');

	// Load the plugin that provides the "uglify" task.
	grunt.loadNpmTasks('grunt-contrib-uglify');

	// Compass
	grunt.loadNpmTasks('grunt-contrib-compass');
	grunt.loadNpmTasks('grunt-contrib-watch');

	// Combine media queries
	grunt.loadNpmTasks('grunt-combine-media-queries');

	// Minify CSS
	grunt.loadNpmTasks('grunt-contrib-cssmin');

	// Auto-prefixer
	grunt.loadNpmTasks('grunt-autoprefixer');

	// LESS
	grunt.loadNpmTasks('grunt-contrib-less');

	// Default task(s).
	grunt.registerTask('default', ['concat', 'uglify', 'compass', 'autoprefixer', 'cssmin']);
};