Skip to content

Commit 55bdc46

Browse files
committed
build scss with webpack
1 parent 2970831 commit 55bdc46

File tree

7 files changed

+382
-144
lines changed

7 files changed

+382
-144
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN npm ci
1414
COPY build*.js webpack.config.js /opt/conditional
1515
COPY frontend /opt/conditional/frontend
1616

17-
RUN npm run build
17+
RUN npm run webpack
1818

1919
FROM docker.io/python:3.12-slim-bookworm
2020
MAINTAINER Computer Science House <[email protected]>

build-css.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,31 @@
11
const { exec } = require('child_process');
22
const path = require('path');
3+
const sass = require('sass');
4+
const fs = require('node:fs');
35

46
// 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
57
// So after I can update node and stuff I'll change this to do it in a sane way, probably in webpack
68

79
const loadPaths = [
10+
"./node_modules/csh-material-bootstrap/dist",
811
"./node_modules/csh-material-bootstrap/dist/css",
912
"./node_modules/datatables.net-bs/css",
1013
"./node_modules/bootstrap-material-datetimepicker/css",
11-
"./node_modules/selectize-scss/src",
1214
"./node_modules/load-awesome/css",
1315
"./node_modules/reveal.js/css",
1416
"./node_modules",
1517
".",
1618
]
1719

18-
const loadPathCommands = loadPaths.map((string) => "-I " + string);
19-
20-
const loadPathString = loadPathCommands.join(" ");
21-
2220
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+
],
3326
})
27+
28+
fs.writeFileSync("conditional/static/css/" + file + ".css", result.css);
3429
}
3530

3631
exec("mkdir -p " + path.resolve("conditional/static/css"))

frontend/javascript/app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ window.addEventListener('unhandledrejection', err => {
1515
import "jquery";
1616
import "bootstrap";
1717
import "./modules";
18+
19+
import "../stylesheets/app.scss"
20+
import "../stylesheets/presentations.scss"

frontend/stylesheets/components/sweet-alert/_sweet-alert.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
// 2014 (c) - Tristan Edwards
33
// github.com/t4t5/sweetalert
44

5+
@use 'pkg:csh-material-bootstrap/sass/variables';
6+
@import 'bootstrap-sass/assets/stylesheets/bootstrap/mixins/vendor-prefixes';
7+
@import 'bootstrap-sass/assets/stylesheets/bootstrap/mixins/forms';
58
@import 'sweet-alert-animations';
6-
@import './node_modules/bootstrap-sass/assets/stylesheets/bootstrap/mixins/forms';
79
// @import 'ball-fall';
810

911
body {

0 commit comments

Comments
 (0)