-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildSCSS.mjs
More file actions
20 lines (17 loc) · 824 Bytes
/
buildSCSS.mjs
File metadata and controls
20 lines (17 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { readFileSync, writeFileSync } from "node:fs";
import { stdout } from "node:process";
import { userscriptify } from "userscriptify";
import { compile } from "sass";
const packageInfo = JSON.parse(readFileSync('package.json', 'utf8'));
// Compile the SASS/SCSS here and pass it in through 'styleRaw"
const options = {};
if (packageInfo?.userscriptify?.style?.match(/\.s[ac]ss$/i)) {
stdout.write("Compiling SASS/SCSS... ");
options.styleRaw = compile(packageInfo.userscriptify.style).css;
console.log("Done");
// Since 'styleRaw' is set, the 'style' value will be ignored by the script
}
// Assuming you have the file path as the value for "main" in package.json
let contents = readFileSync(packageInfo.main, "utf8");
contents = userscriptify(contents, options);
writeFileSync(packageInfo.main, contents);