tasks/asset_hash.js
function writeMappingFile() {
      // The full mapping combines the asset and source map files.
      var fullMapping = {};
      copyObjectProperties(assetFileMapping, fullMapping);
      copyObjectProperties(sourceFileMapping, fullMapping);

      // Sort the keys.
      var sortedMapping = {};
      var sortedAssets = Object.keys(fullMapping).sort();
      sortedAssets.forEach(function(asset) {
        // track which assets were renamed
        // for filename reference replacement
        // (eg. in CSS files referencing renamed images)
        renameInfos.push({
          from: asset,
          fromRegex: new RegExp('\\b' + asset + '\\b', 'g'),
          to: fullMapping[asset]
        });
        sortedMapping[asset] = fullMapping[asset];
      });

      if (options.assetMap) {
        grunt.file.write(options.assetMap, JSON.stringify(sortedMapping, null, 2));
        grunt.log.oklns('Asset map saved as ' + options.assetMap);
      }
    }
function writeMappingFile() {
      // The full mapping combines the asset and source map files.
      var fullMapping = {};
      copyObjectProperties(assetFileMapping, fullMapping);
      copyObjectProperties(sourceFileMapping, fullMapping);

      // Sort the keys.
      var sortedMapping = {};
      var sortedAssets = Object.keys(fullMapping).sort();
      sortedAssets.forEach(function(asset) {
        // track which assets were renamed
        // for filename reference replacement
        // (eg. in CSS files referencing renamed images)
        renameInfos.push({
          from: asset,
          fromRegex: new RegExp('\\b' + asset + '\\b', 'g'),
          to: fullMapping[asset]
        });
        sortedMapping[asset] = fullMapping[asset];
      });

      if (options.assetMap) {
        grunt.file.write(options.assetMap, JSON.stringify(sortedMapping, null, 2));
        grunt.log.oklns('Asset map saved as ' + options.assetMap);
      }
    }
function writeMappingFile ( ) { // The full mapping combines the asset and source map files. var fullMapping = { } ; copyObjectProperties ( assetFileMapping , fullMapping ) ; copyObjectProperties ( sourceFileMapping , fullMapping ) ; // Sort the keys. var sortedMapping = { } ; var sortedAssets = Object . keys ( fullMapping ) . sort ( ) ; sortedAssets . forEach ( function ( asset ) { // track which assets were renamed // for filename reference replacement // (eg. in CSS files referencing renamed images) renameInfos . push ( { from : asset , fromRegex : new RegExp ( '\\b' + asset + '\\b' , 'g' ) , to : fullMapping [ asset ] } ) ; sortedMapping [ asset ] = fullMapping [ asset ] ; } ) ; if ( options . assetMap ) { grunt . file . write ( options . assetMap , JSON . stringify ( sortedMapping , null , 2 ) ) ; grunt . log . oklns ( 'Asset map saved as ' + options . assetMap ) ; } }
Write the accompanying json file that maps non-hashed assets to their hashed locations.
Write the accompanying json file that maps non - hashed assets to their hashed locations .