module.exports = function (grunt) {
    grunt.initConfig({
        copy: {
            main: {
                files: [
                    {
                        expand: false,
                        src: ['node_modules/jquery/dist/jquery.min.js'],
                        dest: 'public/js/jquery.min.js',
                        filter: 'isFile'
                    },
                    {
                        expand: false,
                        src: ['node_modules/phaser/dist/phaser.min.js'],
                        dest: 'public/js/phaser.min.js',
                        filter: 'isFile'
                    },
                ],
            },
        },

        uglify: {
            my_target: {
                files: {
                    'public/js//level1.min.js': ['src/js/level1/*.js'],
                    'public/js//level2.min.js': ['src/js/level2/*.js'],
                    'public/js//level3.min.js': ['src/js/level3/*.js']
                }
            }
        },

        cssmin: {
            options: {
                mergeIntoShorthands: false,
                roundingPrecision: -1
            },
            target: {
                files: {
                    'public/css//app.min.css': ['src/css/*.css']
                }
            }
        },
        minjson: {
            compile: {
                files: {
                    'public/json//level1.json': ['src/json/level1.json'],
                    'public/json//level2.json': ['src/json/level2.json'],
                    'public/json//level3.json': ['src/json/level3.json'],
                    'public/json//level4.json': ['src/json/level4.json'],
                    'public/json//level5.json': ['src/json/level5.json']
                }
            }
        }

    })

    grunt.loadNpmTasks('grunt-minjson');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-uglify-es');
    grunt.loadNpmTasks('grunt-contrib-cssmin');

    grunt.registerTask('json', ['minjson']);
    grunt.registerTask('cp', ['copy']);
    grunt.registerTask('ugl', ['uglify', 'cssmin']);
    grunt.registerTask('default', ['cp', 'ugl', 'json']);
}
