-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
22 lines (17 loc) · 738 Bytes
/
index.js
File metadata and controls
22 lines (17 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'use strict';
var INLINE_COMPRESS_REG = /(<(script|style)([\s\S]+?\b(?:feather|data)-inline-compress\b[^>]*)>)([\s\S]*?)<\/\2>/g;
var ug = require('uglify-js'), clean = require('clean-css');
module.exports = function(content, file, conf){
if(file.isHtmlLike){
var tmp;
content = content.replace(INLINE_COMPRESS_REG, function(_0, _1, _2, _3, _4){
if(_2 == 'script'){
_4 = ug.minify(_4, {fromString: true}).code;
}else{
_4 = clean.process(_4, {processImport: false});
}
return '<' + _2 + _3.replace(/\s*(?:feather|data)-inline-compress\s*/, ' ').replace(/\s*$/, '') + '>' + _4 + '</' + _2 + '>';
});
}
return content;
}