tasks/replace.js
function( str , dest ){
		var _spilt 	= "cb==cb",
			_imgs 	= str.replace( /\s+/gi , " " ).replace( /url\(([^\)]*)\)/gi , _spilt + "$1" + _spilt ).split( _spilt ),
			_md5,
			_dest;
		for( var i = _imgs.length; i--; ){
			if( i % 2 ){
				_img 	= tool.get_resource_path( _imgs[ i ].replace( /[\'|\"|\s]*/gi , "" ) , dest );
				if( !grunt.file.exists( _img ) ){
					continue;
				};
				if( !config.resources[ _img ] ){
					_md5 	= [
						"resources/",
						tool.md5( config.md5 + new Date().getTime() + parseInt( Math.random() * 999999999 ) ),
						_img.replace( /.*(\..*)$/gi , "$1" )
					].join( "" );
					config.resources[ _img ] = _md5;
				} else {
					_md5 = config.resources[ _img ];
				};
				_imgs[ i ] = "url('../" + _md5 + "')";
			};
		};
		return _imgs.join( "" );
	}
function( str , dest ){
		var _spilt 	= "cb==cb",
			_imgs 	= str.replace( /\s+/gi , " " ).replace( /url\(([^\)]*)\)/gi , _spilt + "$1" + _spilt ).split( _spilt ),
			_md5,
			_dest;
		for( var i = _imgs.length; i--; ){
			if( i % 2 ){
				_img 	= tool.get_resource_path( _imgs[ i ].replace( /[\'|\"|\s]*/gi , "" ) , dest );
				if( !grunt.file.exists( _img ) ){
					continue;
				};
				if( !config.resources[ _img ] ){
					_md5 	= [
						"resources/",
						tool.md5( config.md5 + new Date().getTime() + parseInt( Math.random() * 999999999 ) ),
						_img.replace( /.*(\..*)$/gi , "$1" )
					].join( "" );
					config.resources[ _img ] = _md5;
				} else {
					_md5 = config.resources[ _img ];
				};
				_imgs[ i ] = "url('../" + _md5 + "')";
			};
		};
		return _imgs.join( "" );
	}
function ( str , dest ) { var _spilt = "cb==cb" , _imgs = str . replace ( / \s+ / gi , " " ) . replace ( / url\(([^\)]*)\) / gi , _spilt + "$1" + _spilt ) . split ( _spilt ) , _md5 , _dest ; for ( var i = _imgs . length ; i -- ; ) { if ( i % 2 ) { _img = tool . get_resource_path ( _imgs [ i ] . replace ( / [\'|\"|\s]* / gi , "" ) , dest ) ; if ( ! grunt . file . exists ( _img ) ) { continue ; } ; if ( ! config . resources [ _img ] ) { _md5 = [ "resources/" , tool . md5 ( config . md5 + new Date ( ) . getTime ( ) + parseInt ( Math . random ( ) * 999999999 ) ) , _img . replace ( / .*(\..*)$ / gi , "$1" ) ] . join ( "" ) ; config . resources [ _img ] = _md5 ; } else { _md5 = config . resources [ _img ] ; } ; _imgs [ i ] = "url('../" + _md5 + "')" ; } ; } ; return _imgs . join ( "" ) ; }
/*!
修正对应内容的图片/其它资源的引用
@str 	{string} 	内容
@dest 	{string} 	目标文件地址
return 	修正后的内容
/ * ! 修正对应内容的图片 / 其它资源的引用