 module.exports = (grunt) ->
+
+  # Build target.
+  target = grunt.option('target') || 'js'
 
   # Project configuration.
   config =

          bare: true
          sourceMap: true
          sourceMapDir: 'dist/'
        files:
          'dist/moltin.js': [
            'src/moltin.coffee',
            'src/features/storage.coffee',
            'src/features/storage.tvjs.coffee',
            'src/features/*.coffee'
          ]
    preprocess:
      inline:
        options:
          context:
            TARGET: grunt.option('target') || 'js'
          inline: true
        src: 'dist/moltin.js'
    concat:
      options:
        separator: ';'
        banner: '/*! <%= pkg.name %> minified - v<%= pkg.version %> - ' +
          '<%= grunt.template.today("yyyy-mm-dd") %> */' + "\n"
      css:
        src: ['src/css/*.css']
        dest: 'dist/moltin.css'
    karma:
      unit:
        options:

  # These plugins provide necessary tasks.
  grunt.loadNpmTasks 'grunt-contrib-coffee'
  grunt.loadNpmTasks 'grunt-contrib-uglify'
  grunt.loadNpmTasks 'grunt-contrib-compress'
  grunt.loadNpmTasks 'grunt-replace'
  grunt.loadNpmTasks 'grunt-preprocess'
  grunt.loadNpmTasks 'grunt-karma'
  grunt.loadNpmTasks 'grunt-contrib-watch'
  grunt.loadNpmTasks 'grunt-aws-s3'
  grunt.loadNpmTasks 'grunt-contrib-copy'

  # Tasks.
  grunt.registerTask 'build', ['coffee', 'preprocess:inline', 'replace', 'karma', 'uglify', 'compress']
  grunt.registerTask 's3', ['copy:aws', 'aws_s3:production']
