add postcss plugin

This commit is contained in:
Soph :3 2024-08-14 16:47:27 +03:00
parent a8e0de3843
commit 47ac0b329c
Signed by: sophie
GPG key ID: EDA5D222A0C270F2
3 changed files with 23 additions and 0 deletions

BIN
bun.lockb

Binary file not shown.

View file

@ -14,6 +14,7 @@
"esbuild": "^0.23.0",
"marked": "^13.0.3",
"mime-types": "^2.1.35",
"postcss": "^8.4.41",
"preact": "^10.23.1"
}
}

22
src/plugins/postcss.ts Normal file
View file

@ -0,0 +1,22 @@
import { Plugin } from "..";
import postcss from "postcss";
export default class PostCSS extends Plugin {
build: undefined;
name = "postcss";
rewriteTriggers = ["css"];
renameTo = "css";
longLasting = false;
plugins: postcss.AcceptedPlugin[] = [];
constructor(plugins: postcss.AcceptedPlugin[]) {
super();
this.plugins = plugins;
}
async rewriteFile(file: string) {
const data = await postcss(this.plugins).process(file, {from: undefined});
return data.css;
}
}