blog/lib/tasks/css.ts

28 lines
948 B
TypeScript

import postcss, { Result } from "postcss";
import config from "../../postcss.config.js";
import { src, then, synchronise, dest } from "../rx-utils.js";
import { map, lastValueFrom } from "rxjs";
import hashPaths from "../hash.js";
export const css = () =>
lastValueFrom(
src("src/index.css").pipe(
then(
(file) =>
new Promise((resolve) =>
postcss(config.plugins)
.process(file.contents, { from: file.path })
.then((result: Result) => {
file.contents = Buffer.from(result.css);
file.path = "index.css";
resolve(file);
}),
),
),
synchronise(),
hashPaths("css.manifest"),
map(dest("dist/_assets")),
),
);