-
Notifications
You must be signed in to change notification settings - Fork 232
/
inlinecss.js
59 lines (47 loc) · 1.33 KB
/
inlinecss.js
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
var fs = require("fs");
var juice = require("juice");
/*CSS*/
var sourceCss = fs.readFileSync("optimus/css/styles.css", "utf-8");
/*HTML to READ*/
var oneColumn = fs.readFileSync(
"optimus/profiler/templates/one_column.html",
"utf-8",
);
var generalInfo = fs.readFileSync(
"optimus/profiler/templates/general_info.html",
"utf-8",
);
var table = fs.readFileSync("optimus/templates/table.html", "utf-8");
/** ADD STYLE TAG & CONCAT TO THE FILE */
var inlineCssOneColumn = juice("<style>" + sourceCss + "</style>" + oneColumn, {
removeStyleTags: true,
preserveMediaQueries: true,
});
var inlineCssGeneralInfo = juice(
"<style>" + sourceCss + "</style>" + generalInfo,
{ removeStyleTags: true, preserveMediaQueries: true },
);
var inlineCssTable = juice("<style>" + sourceCss + "</style>" + table, {
removeStyleTags: true,
preserveMediaQueries: true,
});
/** CREATE A INLINE-CSS HTML FILE */
fs.writeFile(
"optimus/profiler/templates/out/one_column.html",
inlineCssOneColumn,
function (err) {
if (err) { throw err; }
},
);
fs.writeFile(
"optimus/profiler/templates/out/general_info.html",
inlineCssGeneralInfo,
function (err) {
if (err) { throw err; }
},
);
fs.writeFile("optimus/templates/out/table.html",
inlineCssTable,
function (err) {
if (err) { throw err; }
});