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

        src: ['*.min.js', '*.min.css', '*.min.map']
        dest: 'dist/gzip/'
    watch:
      files: ['src/*.coffee', 'src/features/*.coffee', 'src/css/*.css']
      tasks: ['coffee', 'preprocess:inline', 'concat', 'karma', 'uglify', 'cssmin', 'compress']

  # Do we have credentials?
  if grunt.file.exists('aws-credentials.json')

          bare: true
          sourceMap: true
          sourceMapDir: 'dist/'
        files: [
          {
            dest: 'dist/moltin.' + ( if target != 'js' then target + '.' else '' ) + 'js'
            src: [
              'src/moltin.coffee',
              'src/' + target + '/ajax.coffee',
              'src/' + target + '/storage.coffee',
              'src/abstract.coffee',
              'src/features/*.coffee'
              'src/' + target + '/export.coffee'
            ]
          }
        ]
    preprocess:
      inline:
        options:
          context:
            TARGET: target
          inline: true
        src: 'dist/moltin.' + ( if target != 'js' then target + '.' else '' ) + 'js'
    replace:
      dist:
        options:
          patterns: [
            {
              match: /[\t]+;\n/g,
              replacement: () ->
                return ''
            }
          ]
        files: [
          {
            expand: true,
            flatten: true,
            src: ['dist/moltin.' + ( if target != 'js' then target + '.' else '' ) + 'js'],
            dest: 'dist/'
          }
        ]
    karma:
      unit:
        options:
