module.exports = function (grunt) {

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

    grunt.initConfig({
        sass: {
            options: {
                sourceMap: false
            },
            build: {
                files: {
                    'dist/css/fractal.css': 'assets/scss/build.scss'
                }
            }
        },
        postcss: {
            options: {
                map: false,
                processors: [
                    require('autoprefixer')({
                        browsers: ['last 2 versions', 'ie 10']
                    })
                ]
            },
            build: {
                src: 'dist/css/fractal.css'
            }
        },
        copy: {
            fonts: {
                expand: true,
                src: ['**/*', '!**/latin/**'],
                dest: 'dist/fonts/',
                cwd: 'assets/fonts/'
            },
            img: {
                expand: true,
                src: ['**/*'],
                dest: 'dist/img/',
                cwd: 'assets/img/'
            },
            favicon: {
                expand: true,
                src: ['favicon.ico'],
                dest: 'dist/',
                cwd: 'assets/'
            },
            js: {
                expand: true,
                src: ['**/*', '!**/latin/**'],
                dest: 'dist/js/ace/',
                cwd: 'assets/js/vendor/ace/'
            },
        },
        uglify: {
            build: {
                files: {
                    'dist/js/fractal.js': [
                        'assets/js/vendor/jquery.js',
                        'assets/js/vendor/iframeResizer.js',
                        'assets/js/vendor/fastclick.js',
                        'assets/js/vendor/pjax.js',
                        'assets/js/core.js',
                        'assets/js/components/*',
                    ],
                    'dist/js/preview.js': [
                        'assets/js/vendor/iframeResizer.contentWindow.js'
                    ]
                }
            }
        },
        watch: {
            css: {
                files: ['assets/scss/**/*.scss'],
                tasks: ['sass', 'postcss'],
                options: {},
            },
            js: {
                files: ['assets/js/**/*.js'],
                tasks: ['uglify'],
                options: {},
            },
            fonts: {
                files: ['assets/fonts/**/*'],
                tasks: ['copy'],
                options: {},
            },
        },
    });

    grunt.registerTask('default', ['sass', 'postcss', 'uglify', 'copy']);
}
