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

    sass: {
      dist: {
        options: {
          style: "compressed",
        },
        files: [
          {
            expand: true,
            cwd: "assets/styles",
            src: ["**/*.scss"],
            dest: "public/css",
            ext: ".css",
          },
        ],
      },
    },

    uglify: {
      options: {
        sourceMap: true,
        compress: true,
      },
      files: {
        expand: true,
        flatten: true,
        cwd: "assets/scripts",
        src: ["*.js"],
        dest: "public/js",
        ext: ".js",
      },
    },

    copy: {
      images: {
        files: [{
          expand: true,
          cwd: 'assets/img/',
          src: '**/*',
          dest: 'public/img/'
        }]
      }
    },

    watch: {
      css: {
        files: ["assets/styles/**/*.scss"],
        tasks: ["sass"],
        options: {
          atBegin: true,
          spawn: false,
        },
      },
      js: {
        files: ["assets/scripts/**/*.js"],
        tasks: ["uglify"],
        options: {
          atBegin: true,
          spawn: false,
        },
      },
      img: {
        files: ["assets/img/**/*"],
        tasks: ["copy:images"],
        options: {
          atBegin: true,
          spawn: false,
        }
      },
    },
  });

  // Load plugins.
  grunt.loadNpmTasks("grunt-contrib-watch");
  grunt.loadNpmTasks("grunt-contrib-sass");
  grunt.loadNpmTasks("grunt-contrib-uglify");
  grunt.loadNpmTasks("grunt-contrib-copy");

  // CLI tasks.
  grunt.registerTask("default", ["sass", "uglify", "copy:images"]);
};
