|
1 | 1 | const { exec } = require('child_process'); |
2 | 2 | const path = require('path'); |
| 3 | +const sass = require('sass'); |
| 4 | +const fs = require('node:fs'); |
3 | 5 |
|
4 | 6 | // yes I know this is awkward. I want to actually use the node libraries but that gets SUBSTANTIALLY easier when node and all the dependinces are updated |
5 | 7 | // So after I can update node and stuff I'll change this to do it in a sane way, probably in webpack |
6 | 8 |
|
7 | 9 | const loadPaths = [ |
| 10 | + "./node_modules/csh-material-bootstrap/dist", |
8 | 11 | "./node_modules/csh-material-bootstrap/dist/css", |
9 | 12 | "./node_modules/datatables.net-bs/css", |
10 | 13 | "./node_modules/bootstrap-material-datetimepicker/css", |
11 | | - "./node_modules/selectize-scss/src", |
12 | 14 | "./node_modules/load-awesome/css", |
13 | 15 | "./node_modules/reveal.js/css", |
14 | 16 | "./node_modules", |
15 | 17 | ".", |
16 | 18 | ] |
17 | 19 |
|
18 | | -const loadPathCommands = loadPaths.map((string) => "-I " + string); |
19 | | - |
20 | | -const loadPathString = loadPathCommands.join(" "); |
21 | | - |
22 | 20 | function compileFile(file) { |
23 | | - // you can use the node package but it doesn't like the version of node we're using for this rn fix later tm |
24 | | - const cmd = "sass " + loadPathString + " " + "frontend/stylesheets/" + file + ".scss" + " conditional/static/css/" + file + ".css"; |
25 | | - |
26 | | - exec(cmd, (error, stdout, stderr) => { |
27 | | - console.log(`stdout: ${stdout}`); |
28 | | - console.error(`stderr: ${stderr}`); |
29 | | - if (error) { |
30 | | - console.error(`exec error: ${error}`); |
31 | | - throw error; |
32 | | - } |
| 21 | + const result = sass.compile("frontend/stylesheets/" + file + ".scss", { |
| 22 | + loadPaths: loadPaths, |
| 23 | + importers: [ |
| 24 | + new sass.NodePackageImporter() |
| 25 | + ], |
33 | 26 | }) |
| 27 | + |
| 28 | + fs.writeFileSync("conditional/static/css/" + file + ".css", result.css); |
34 | 29 | } |
35 | 30 |
|
36 | 31 | exec("mkdir -p " + path.resolve("conditional/static/css")) |
|
0 commit comments