You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							27 lines
						
					
					
						
							773 B
						
					
					
				
			
		
		
	
	
							27 lines
						
					
					
						
							773 B
						
					
					
				const { interpolateName, getHashDigest } = require('loader-utils'); | 
						|
 | 
						|
/** | 
						|
 * @param {PostHTMLTree} tree | 
						|
 * @return {Object} Node | 
						|
 */ | 
						|
exports.getRoot = function getRoot(tree) { | 
						|
  return tree.find(node => typeof node === 'object' && 'tag' in node); | 
						|
}; | 
						|
 | 
						|
/** | 
						|
 * @param {string|Function} pattern | 
						|
 * @param {string} resourcePath | 
						|
 * @param {Object} [options] | 
						|
 * @param {string} options.context | 
						|
 * @param {string} options.content | 
						|
 * @param {string} options.regExp | 
						|
 */ | 
						|
exports.interpolate = function interpolate(pattern, resourcePath, options = null) { | 
						|
  const opts = Object.assign({ context: process.cwd() }, options); | 
						|
 | 
						|
  return interpolateName({ resourcePath }, pattern, opts); | 
						|
}; | 
						|
 | 
						|
exports.getHash = function getHash(content) { | 
						|
  return getHashDigest(content, 'md5', 'hex', 6); | 
						|
};
 | 
						|
 |