-
Notifications
You must be signed in to change notification settings - Fork 3
/
inline-css.js
41 lines (35 loc) · 971 Bytes
/
inline-css.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
const juice = require('juice');
const fs = require('fs');
// List of HTML files to be updated
const htmlFiles = [
'dist/index.html',
// 'dist/index-ar.html',
// 'dist/index-cs.html',
// 'dist/index-de.html',
// 'dist/index-es.html',
// 'dist/index-fr.html',
// 'dist/index-it.html',
// 'dist/index-ja.html',
// 'dist/index-ko.html',
// 'dist/index-pl.html',
// 'dist/index-pt.html',
// 'dist/index-ru.html',
// 'dist/index-tr.html',
// 'dist/index-zh-CN.html',
// 'dist/index-zh-TW.html'
];
// Inline CSS for each HTML file
htmlFiles.forEach(htmlFile => {
juice.juiceFile(htmlFile, {}, (err, inlinedHtml) => {
if (err) {
console.error(`🚨 Error inlining CSS for file ${htmlFile}: ${err}`);
return;
}
fs.writeFile(htmlFile, inlinedHtml, 'utf8', err => {
if (err) {
console.error(`🚨 Error writing file ${htmlFile}: ${err}`);
return;
}
});
});
});