tasks/minified.js
function(file){

      // Sandboxed variables
      var filePath = '';
      // Read file source
      var src       = grunt.file.read(file);
      // Get file name
      var filename  = path.basename(file);
      // set file extention
      if(_opts.ext) {
        filename = filename.replace('.js', _opts.ext);
      }


      if(_opts.sourcemap){
        uglifyOpts.outSourceMap = filename + '.map';
        mapDest = _destPath + uglifyOpts.outSourceMap;
      }
      // Minify file source
      var result = uglify.minify(file, uglifyOpts);

      if(_opts.sourcemap){

        // Write source map to file
        grunt.file.write( mapDest, result.map );
      }

      var minSrc = result.code;

      // Verbose output by default for now
      if(_opts.verbose){

        grunt.log.ok(filename.yellow + ': original size: ' + String(src.length).cyan + ' bytes' + ', minified size: ' + String(minSrc.length).cyan + ' bytes.');
        if(_opts.sourcemap){
          grunt.log.ok('sourcemap generated to ' + uglifyOpts.outSourceMap.yellow);
        }
      } else {
        var _non_verbose_output = filename.yellow + ' minified';

        if(_opts.sourcemap){
          _non_verbose_output += ', and sourcemapped to ' + uglifyOpts.outSourceMap.yellow;
        }
        grunt.log.ok(_non_verbose_output);
      }





      // Set destination
      filePath = (_isMirrorSource) ? changeFilePath(file) : _destPath;
      minDest = filePath + filename;

      // Write minified sorce to destination file
      grunt.file.write( minDest, minSrc );

    }
function(file){

      // Sandboxed variables
      var filePath = '';
      // Read file source
      var src       = grunt.file.read(file);
      // Get file name
      var filename  = path.basename(file);
      // set file extention
      if(_opts.ext) {
        filename = filename.replace('.js', _opts.ext);
      }


      if(_opts.sourcemap){
        uglifyOpts.outSourceMap = filename + '.map';
        mapDest = _destPath + uglifyOpts.outSourceMap;
      }
      // Minify file source
      var result = uglify.minify(file, uglifyOpts);

      if(_opts.sourcemap){

        // Write source map to file
        grunt.file.write( mapDest, result.map );
      }

      var minSrc = result.code;

      // Verbose output by default for now
      if(_opts.verbose){

        grunt.log.ok(filename.yellow + ': original size: ' + String(src.length).cyan + ' bytes' + ', minified size: ' + String(minSrc.length).cyan + ' bytes.');
        if(_opts.sourcemap){
          grunt.log.ok('sourcemap generated to ' + uglifyOpts.outSourceMap.yellow);
        }
      } else {
        var _non_verbose_output = filename.yellow + ' minified';

        if(_opts.sourcemap){
          _non_verbose_output += ', and sourcemapped to ' + uglifyOpts.outSourceMap.yellow;
        }
        grunt.log.ok(_non_verbose_output);
      }





      // Set destination
      filePath = (_isMirrorSource) ? changeFilePath(file) : _destPath;
      minDest = filePath + filename;

      // Write minified sorce to destination file
      grunt.file.write( minDest, minSrc );

    }
function ( file ) { // Sandboxed variables var filePath = '' ; // Read file source var src = grunt . file . read ( file ) ; // Get file name var filename = path . basename ( file ) ; // set file extention if ( _opts . ext ) { filename = filename . replace ( '.js' , _opts . ext ) ; } if ( _opts . sourcemap ) { uglifyOpts . outSourceMap = filename + '.map' ; mapDest = _destPath + uglifyOpts . outSourceMap ; } // Minify file source var result = uglify . minify ( file , uglifyOpts ) ; if ( _opts . sourcemap ) { // Write source map to file grunt . file . write ( mapDest , result . map ) ; } var minSrc = result . code ; // Verbose output by default for now if ( _opts . verbose ) { grunt . log . ok ( filename . yellow + ': original size: ' + String ( src . length ) . cyan + ' bytes' + ', minified size: ' + String ( minSrc . length ) . cyan + ' bytes.' ) ; if ( _opts . sourcemap ) { grunt . log . ok ( 'sourcemap generated to ' + uglifyOpts . outSourceMap . yellow ) ; } } else { var _non_verbose_output = filename . yellow + ' minified' ; if ( _opts . sourcemap ) { _non_verbose_output += ', and sourcemapped to ' + uglifyOpts . outSourceMap . yellow ; } grunt . log . ok ( _non_verbose_output ) ; } // Set destination filePath = ( _isMirrorSource ) ? changeFilePath ( file ) : _destPath ; minDest = filePath + filename ; // Write minified sorce to destination file grunt . file . write ( minDest , minSrc ) ; }
Set up callback function for file iteration
Set up callback function for file iteration