Skip to content

Commit

Permalink
fix: move PostCSS config into gulpfile
Browse files Browse the repository at this point in the history
  • Loading branch information
doamatto committed Jan 26, 2025
1 parent b7ae2ce commit a9e948e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 38 deletions.
31 changes: 20 additions & 11 deletions gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
getExtensionAPI,
} from "./src/build/utils";

import * as purgecss from "@fullhuman/postcss-purgecss";

const gulp = require("gulp");
const postcss = require("gulp-postcss");
const fs = require("node:fs");
Expand Down Expand Up @@ -73,11 +75,7 @@ gulp.task("build general pages", () => {
})
.pipe(through.obj((file, _, cb) => { // change to .html extension
if (file.isBuffer()) {
const fp = path.format({
dir: path.dirname(file.path),
name: path.basename(file.path, ".hbs"),
ext: '.html'
})
file.path = file.path.replace(".hbs", ".html")
}
cb(null, file);
}))
Expand Down Expand Up @@ -120,19 +118,30 @@ gulp.task("collect product icons", () => {
});

gulp.task("build css", async () => {
const purgecssConf = purgecss.default({
content: ["./src/**/*.hbs", "./src/**/*.js", "./src/**/*.ts", "./gulpfile.ts"],
defaultExtractor: (content) => content.match(/[\w-/:]+(?<!:)/g) || [],
});
const plugins = [
require("postcss-import"),
require("tailwindcss")("tailwind.config.js"),
require("autoprefixer"),
...(process.env.NODE_ENV === "production" ? [purgecssConf] : []),
];

return gulp
.src(["./src/static/css/base.scss"])
.pipe(postcss())
.pipe(postcss(plugins, {
syntax: require("postcss-scss")
}))
.on("error", (err) => console.error(err))
.pipe(through.obj((file, _, cb) => { // change to .css extension
if (file.isBuffer()) {
const fp = path.format({
dir: path.dirname(file.path),
name: path.basename(file.path, ".scss"),
ext: '.css'
})
file.path = file.path.replace(".scss", ".css")
}
cb(null, file);
}))
.on("error", (err) => console.error(err))
.pipe(gulp.dest("./dist/static/css/"));
});

Expand Down
27 changes: 0 additions & 27 deletions postcss.config.js

This file was deleted.

0 comments on commit a9e948e

Please sign in to comment.