@@ -8,6 +8,7 @@ var SourceNode = require("source-map").SourceNode;
8
8
var loaderUtils = require ( "loader-utils" ) ;
9
9
var url = require ( "url" ) ;
10
10
var assign = require ( "object-assign" ) ;
11
+ var compile = require ( "es6-templates" ) . compile ;
11
12
12
13
function randomIdent ( ) {
13
14
return "xxxHTMLLINKxxx" + Math . random ( ) + Math . random ( ) + "xxx" ;
@@ -37,15 +38,14 @@ module.exports = function(content) {
37
38
content = [ content ] ;
38
39
links . forEach ( function ( link ) {
39
40
if ( ! loaderUtils . isUrlRequest ( link . value , root ) ) return ;
40
-
41
+
41
42
var uri = url . parse ( link . value ) ;
42
43
if ( uri . hash !== null && uri . hash !== undefined ) {
43
- uri . hash = null ;
44
- link . value = uri . format ( ) ;
45
- link . length = link . value . length ;
44
+ uri . hash = null ;
45
+ link . value = uri . format ( ) ;
46
+ link . length = link . value . length ;
46
47
}
47
48
48
-
49
49
do {
50
50
var ident = randomIdent ( ) ;
51
51
} while ( data [ ident ] ) ;
@@ -77,7 +77,14 @@ module.exports = function(content) {
77
77
78
78
content = htmlMinifier . minify ( content , minimizeOptions ) ;
79
79
}
80
- return "module.exports = " + JSON . stringify ( content ) . replace ( / x x x H T M L L I N K x x x [ 0 - 9 \. ] + x x x / g, function ( match ) {
80
+
81
+ if ( query . interpolate ) {
82
+ content = compile ( '`' + content + '`' ) . code ;
83
+ } else {
84
+ content = JSON . stringify ( content ) ;
85
+ }
86
+
87
+ return "module.exports = " + content . replace ( / x x x H T M L L I N K x x x [ 0 - 9 \. ] + x x x / g, function ( match ) {
81
88
if ( ! data [ match ] ) return match ;
82
89
return '" + require(' + JSON . stringify ( loaderUtils . urlToRequest ( data [ match ] , root ) ) + ') + "' ;
83
90
} ) + ";" ;
0 commit comments