-
Notifications
You must be signed in to change notification settings - Fork 0
/
replace-css.ts
38 lines (34 loc) · 974 Bytes
/
replace-css.ts
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
// this script replaces placeholders with binding expressions in resulting CSS file
// tslint:disable-next-line:no-namespace
namespace css {
// tslint:disable-next-line:no-var-requires
let replace = require("replace-in-file");
let fs = require("fs");
let optionsCss = {
files: "src/elements/colours/at-colours.css",
from: [
/primaryColor/g,
/secondaryColor/g,
/errorColor/g,
/successColor/g,
/headerColor/g,
/menuButtonColor/g,
],
to: [
"${mdCs.primaryColor}",
"${mdCs.secondaryColor}",
"${mdCs.errorColor}",
"${mdCs.successColor}",
"${atCs.headerColor}",
"${atCs.menuButtonColor}",
]
};
replace.sync(optionsCss);
let styles = fs.readFileSync("./" + optionsCss.files);
let optionsHtml = {
files: "src/elements/colours/at-colours.html",
from: /(\/\* style-replace-start \*\/)[\s\S]*(\/\* style-replace-end \*\/)/,
to: "$1" + styles + "$2"
};
replace.sync(optionsHtml);
}