Skip to content

Commit b7ae2ce

Browse files
committed
chore: partial revert of 11f35ee
- Removes esbuild system (may™ return in future) - Moves SASS back to src/static/css/ (rather than src/css/) - Re-adds PostCSS, Gulp tasks for SASS transpilation
1 parent 2c98280 commit b7ae2ce

File tree

10 files changed

+187
-172
lines changed

10 files changed

+187
-172
lines changed

gulpfile.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from "./src/build/utils";
1515

1616
const gulp = require("gulp");
17+
const postcss = require("gulp-postcss");
1718
const fs = require("node:fs");
1819
const path = require("node:path");
1920
const through = require("through2");
@@ -22,7 +23,7 @@ const rubric: RubricQuestion[] = loadRubric();
2223
const contributors: Contributor[] = loadContributors();
2324
const products: Product[] = loadProducts(rubric, contributors);
2425

25-
gulp.task("clean", () => {
26+
gulp.task("clean", async () => {
2627
return fs.rmSync(path.join(__dirname, "dist"), {
2728
recursive: true,
2829
force: true,
@@ -94,11 +95,57 @@ gulp.task(
9495
)
9596
);
9697

98+
gulp.task("collect dependencies", () => {
99+
return gulp
100+
.src(["./node_modules/lunr/lunr.min.js"])
101+
.pipe(gulp.dest("./dist/static/deps/"));
102+
});
103+
104+
gulp.task("collect static", () => {
105+
return gulp
106+
.src([
107+
"./src/static/**/*",
108+
"./node_modules/@fortawesome/fontawesome-free/**/*.{woff2,woff}",
109+
"!./src/static/**/*.{css,scss}",
110+
])
111+
.pipe(gulp.dest("./dist/static/"));
112+
});
113+
114+
gulp.task("collect root favicon", () => {
115+
return gulp.src(["./src/static/img/*.ico"]).pipe(gulp.dest("./dist/"));
116+
});
117+
118+
gulp.task("collect product icons", () => {
119+
return gulp.src(["./icons/**/*"]).pipe(gulp.dest("./dist/static/icons/"));
120+
});
121+
122+
gulp.task("build css", async () => {
123+
return gulp
124+
.src(["./src/static/css/base.scss"])
125+
.pipe(postcss())
126+
.pipe(through.obj((file, _, cb) => { // change to .css extension
127+
if (file.isBuffer()) {
128+
const fp = path.format({
129+
dir: path.dirname(file.path),
130+
name: path.basename(file.path, ".scss"),
131+
ext: '.css'
132+
})
133+
}
134+
cb(null, file);
135+
}))
136+
.pipe(gulp.dest("./dist/static/css/"));
137+
});
138+
97139
gulp.task(
98140
"default",
99141
gulp.series([
100142
"clean",
101143
"build pages",
144+
"collect dependencies",
145+
"collect static",
146+
"collect product icons",
147+
"collect root favicon",
148+
"build css"
102149
])
103150
);
104151

package-lock.json

Lines changed: 110 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"autoprefixer": "^10.4.20",
1515
"gulp": "^5.0.0",
1616
"gulp-hb": "^8.0.0",
17+
"gulp-postcss": "^10.0.0",
1718
"hbl-arrays": "^0.1.2",
1819
"hbl-cmark": "^0.1.2",
1920
"hbl-comparison": "^0.1.4",
@@ -27,7 +28,7 @@
2728
"postcss-import": "^16.1.0",
2829
"postcss-scss": "^4.0.9",
2930
"simple-git": "^3.27.0",
30-
"tailwindcss": "^2.1.2",
31+
"tailwindcss": "^2.2.19",
3132
"through2": "^4.0.2",
3233
"ts-node": "^10.9.2",
3334
"typescript": "^5.7.3"

postcss.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const purgecss = require('@fullhuman/postcss-purgecss')({
2+
// Specify the paths to all of the template files in your project
3+
content: ["./src/**/*.hbs", "./src/**/*.js", "./src/**/*.ts", "./gulpfile.ts"],
4+
5+
// This is the function used to extract class names from your templates
6+
defaultExtractor: content => {
7+
// Capture as liberally as possible, including things like `h-(screen-1.5)`
8+
const broadMatches = content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || []
9+
10+
// Capture classes within other delimiters like .block(class="w-1/2") in Pug
11+
const innerMatches = content.match(/[^<>"'`\s.()]*[^<>"'`\s.():]/g) || []
12+
13+
return broadMatches.concat(innerMatches)
14+
}
15+
});
16+
17+
module.exports = {
18+
plugins: [
19+
require("postcss-import"),
20+
require("tailwindcss")("tailwind.config.js"),
21+
require("autoprefixer"),
22+
...process.env.NODE_ENV === 'production'
23+
? [purgecss]
24+
: []
25+
],
26+
syntax: require("postcss-scss")
27+
}

0 commit comments

Comments
 (0)