-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (26 loc) · 769 Bytes
/
index.js
File metadata and controls
32 lines (26 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// retain all original lines for numbering, but disable eslint so as to not trigger rules such as no-multiple-empty-lines and others
var generateReplacement = function (lines) {
var str = '/* eslint-disable */{', i = 1;
for (;i < lines; i++) str += '\n';
return str += '}/* eslint-enable */';
}
var Plugin = {
preprocess: function(text) {
var re = /<style>([\s\S]*?)<\/style>/g;
var cleaned = text, match;
while(match = re.exec(text)) {
cleaned = cleaned.replace(match[0], generateReplacement(match[0].split(/\n/g).length));
}
return [ cleaned ];
},
postprocess: function (messages, filename) {
return messages[0];
}
};
module.exports = {
processors: {
'.js': Plugin,
'.jsx': Plugin,
'.cssx': Plugin
}
}