'use strict';

module.exports = function(grunt) {

    //Paths to folders
    var paths = {
        app: 'app',
        assets: 'assets',
        css: 'public/css',
        js: 'public/js',
        fonts: 'public/fonts',
        views: 'app/views'
    };

    //Load tasks in Gruntfile
    require('jit-grunt')(grunt);


    // Project configuration.
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
        paths: paths,
        autoprefixer: {
            options: {
                map: true
            },
            css: {
                expand: true,
                flatten: true,
                src: '<%= paths.css %>/*.css',
                dest: '<%= paths.css %>'
            },
        },
        concat: {
            options: {
                separator: ';',
                stripBanners: true,
                banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - '
                    + '<%= grunt.template.today("yyyy-mm-dd") %> */',
                sourceMap: true
            },
            js: {
                files: {
                    '<%= paths.js %>/main.js %>': '<%= paths.assets %>/js/*.js %>'
                }
            }

        },
        clean: {
            js: ['<%= paths.js%>'],
            css: ['<%= paths.css%>']
        },
        cssmin: {
            minify: {
                expand: true,
                cwd: '<%= paths.css %>',
                src: ['*.css', '!*.min.css'],
                dest: '',
                ext: '.min.css'
            }
        },
        jshint: {
            all: ['Gruntfile.js']
        },
        sass: {
            dist: {
                files: [{
                    src: ['<%= paths.assets %>/sass/master.scss'],
                    dest: '<%= paths.css %>/master.css'
                }],

                options: {
                    loadPath: [
                        'vendor/bower_components/bourbon/dist',
                        'vendor/bower_components/neat/app/assets/stylesheets'
                    ]
                }
            }
        },
        uglify: {
			options: {
				banner: '/*! <%= pkg.name %> - <%= pkg.author %> -<%= grunt.template.today("yyyy-mm-dd") %> */\n'
			},
			build: {
				src: 'src/<%= pkg.name %>.js',
				dest: 'build/<%= pkg.name %>.min.js'
			}
		},
        watch: {
            sass: {
                files: '<%= paths.assets %>/sass/**/*.scss',
                tasks: ['sass']
            }
        }
	});

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