@@ -65,6 +65,34 @@ module.exports = function(content) {
65
65
} ) ;
66
66
content . reverse ( ) ;
67
67
content = content . join ( "" ) ;
68
+
69
+ if ( config . interpolate ) {
70
+ var reg = / \$ \{ r e q u i r e \( [ ^ ) ] * \) \} / g;
71
+ var result ;
72
+ var reqList = [ ] ;
73
+ while ( result = reg . exec ( content ) ) {
74
+ reqList . push ( {
75
+ length : result [ 0 ] . length ,
76
+ start : result . index ,
77
+ value : result [ 0 ]
78
+ } )
79
+ }
80
+ reqList . reverse ( ) ;
81
+ content = [ content ] ;
82
+ reqList . forEach ( function ( link ) {
83
+ var x = content . pop ( ) ;
84
+ do {
85
+ var ident = randomIdent ( ) ;
86
+ } while ( data [ ident ] ) ;
87
+ data [ ident ] = link . value . substring ( 11 , link . length - 3 )
88
+ content . push ( x . substr ( link . start + link . length ) ) ;
89
+ content . push ( ident ) ;
90
+ content . push ( x . substr ( 0 , link . start ) ) ;
91
+ } ) ;
92
+ content . reverse ( ) ;
93
+ content = content . join ( "" ) ;
94
+ }
95
+
68
96
if ( typeof config . minimize === "boolean" ? config . minimize : this . minimize ) {
69
97
var minimizeOptions = assign ( { } , config ) ;
70
98
@@ -89,15 +117,12 @@ module.exports = function(content) {
89
117
90
118
content = htmlMinifier . minify ( content , minimizeOptions ) ;
91
119
}
120
+
121
+ content = JSON . stringify ( content ) ;
92
122
93
- if ( config . interpolate ) {
94
- content = compile ( '`' + content + '`' ) . code ;
95
- } else {
96
- content = JSON . stringify ( content ) ;
97
- }
98
-
99
- 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 ) {
123
+ 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 ) {
100
124
if ( ! data [ match ] ) return match ;
101
125
return '" + require(' + JSON . stringify ( loaderUtils . urlToRequest ( data [ match ] , root ) ) + ') + "' ;
102
126
} ) + ";" ;
127
+
103
128
}
0 commit comments