@@ -14,22 +14,31 @@ function randomIdent() {
1414 return "xxxHTMLLINKxxx" + Math . random ( ) + Math . random ( ) + "xxx" ;
1515} ;
1616
17+ function getLoaderConfig ( context ) {
18+ var query = loaderUtils . parseQuery ( context . query ) ;
19+ var configKey = query . config || 'htmlLoader' ;
20+ var config = context . options && context . options . hasOwnProperty ( configKey ) ? context . options [ configKey ] : { } ;
21+
22+ delete query . config ;
23+
24+ return assign ( query , config ) ;
25+ }
1726
1827module . exports = function ( content ) {
1928 this . cacheable && this . cacheable ( ) ;
20- var query = loaderUtils . parseQuery ( this . query ) ;
29+ var config = getLoaderConfig ( this ) ;
2130 var attributes = [ "img:src" ] ;
22- if ( query . attrs !== undefined ) {
23- if ( typeof query . attrs === "string" )
24- attributes = query . attrs . split ( " " ) ;
25- else if ( Array . isArray ( query . attrs ) )
26- attributes = query . attrs ;
27- else if ( query . attrs === false )
31+ if ( config . attrs !== undefined ) {
32+ if ( typeof config . attrs === "string" )
33+ attributes = config . attrs . split ( " " ) ;
34+ else if ( Array . isArray ( config . attrs ) )
35+ attributes = config . attrs ;
36+ else if ( config . attrs === false )
2837 attributes = [ ] ;
2938 else
30- throw new Error ( "Invalid value to query parameter attrs" ) ;
39+ throw new Error ( "Invalid value to config parameter attrs" ) ;
3140 }
32- var root = query . root ;
41+ var root = config . root ;
3342 var links = attrParse ( content , function ( tag , attr ) {
3443 return attributes . indexOf ( tag + ":" + attr ) >= 0 ;
3544 } ) ;
@@ -57,8 +66,8 @@ module.exports = function(content) {
5766 } ) ;
5867 content . reverse ( ) ;
5968 content = content . join ( "" ) ;
60- if ( typeof query . minimize === "boolean" ? query . minimize : this . minimize ) {
61- var minimizeOptions = assign ( { } , query ) ;
69+ if ( typeof config . minimize === "boolean" ? config . minimize : this . minimize ) {
70+ var minimizeOptions = assign ( { } , config ) ;
6271
6372 [
6473 "removeComments" ,
@@ -82,7 +91,7 @@ module.exports = function(content) {
8291 content = htmlMinifier . minify ( content , minimizeOptions ) ;
8392 }
8493
85- if ( query . interpolate ) {
94+ if ( config . interpolate ) {
8695 content = compile ( '`' + content + '`' ) . code ;
8796 } else {
8897 content = JSON . stringify ( content ) ;
0 commit comments