@@ -6,14 +6,16 @@ var ejs = require('ejs'),
6
6
merge = require ( 'merge' ) ;
7
7
8
8
9
- module . exports = function ( source ) {
9
+ module . exports = function ( source ) {
10
10
this . cacheable && this . cacheable ( ) ;
11
-
12
11
var query = typeof this . query === 'object' ? this . query : utils . parseQuery ( this . query ) ;
13
12
var _options = typeof this . options === 'object' ? this . options [ 'ejs-compiled-loader' ] || { } : { } ;
14
13
_options = typeof utils . getOptions === 'function' ? merge ( utils . getOptions ( this ) , _options ) : _options ;
15
14
var opts = merge ( _options , query ) ;
16
- opts . client = true ;
15
+
16
+ if ( opts . client == undefined ) {
17
+ opts . client = true ;
18
+ }
17
19
18
20
// Skip compile debug for production when running with
19
21
// webpack --optimize-minimize
@@ -31,11 +33,14 @@ module.exports = function (source) {
31
33
var template = ejs . compile ( source , opts ) ;
32
34
33
35
// Beautify javascript code
34
- if ( ! this . minimize && opts . beautify !== false ) {
35
- var ast = UglifyJS . parse ( template . toString ( ) ) ;
36
- ast . figure_out_scope ( ) ;
37
- template = ast . print_to_string ( { beautify : true } ) ;
36
+ if ( this . loaders . length > 1 ) {
37
+ template = JSON . stringify ( template ( ) ) ;
38
+ } else {
39
+ if ( ! this . minimize && opts . beautify !== false ) {
40
+ var ast = UglifyJS . parse ( template . toString ( ) ) ;
41
+ ast . figure_out_scope ( ) ;
42
+ template = ast . print_to_string ( { beautify : true } ) ;
43
+ }
38
44
}
39
-
40
45
return 'module.exports = ' + template ;
41
46
} ;
0 commit comments