Skip to content
This repository was archived by the owner on May 16, 2024. It is now read-only.

Commit c4a9395

Browse files
committed
some improves, works with webpack-html-plugin and like loader with extract loader
1 parent f7a7e34 commit c4a9395

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

index.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ var ejs = require('ejs'),
66
merge = require('merge');
77

88

9-
module.exports = function (source) {
9+
module.exports = function(source) {
1010
this.cacheable && this.cacheable();
11-
1211
var query = typeof this.query === 'object' ? this.query : utils.parseQuery(this.query);
1312
var _options = typeof this.options === 'object' ? this.options['ejs-compiled-loader'] || {} : {};
1413
_options = typeof utils.getOptions === 'function' ? merge(utils.getOptions(this), _options) : _options;
1514
var opts = merge(_options, query);
16-
opts.client = true;
15+
16+
if (opts.client == undefined) {
17+
opts.client = true;
18+
}
1719

1820
// Skip compile debug for production when running with
1921
// webpack --optimize-minimize
@@ -31,11 +33,14 @@ module.exports = function (source) {
3133
var template = ejs.compile(source, opts);
3234

3335
// 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+
}
3844
}
39-
4045
return 'module.exports = ' + template;
4146
};

0 commit comments

Comments
 (0)