This repository has been archived by the owner on May 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
__run.js
62 lines (55 loc) · 1.45 KB
/
__run.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { AtRule, Comment, Declaration } from "postcss";
import { extension, stylesHint } from "../scss/stuff.js";
/** @type {import("../..").AdderRun<import("./__info.js").Options>} */
export const run = async ({ install, updateCss }) => {
await updateCss({
path: `/src/variables.${extension}`,
async style({ postcss }) {
postcss.append(
new Comment({
text: "https://github.com/jgthms/bulma/issues/1293",
}),
);
postcss.append(
new Declaration({
prop: "$body-overflow-y",
value: "auto",
}),
);
return {
postcss,
};
},
});
await updateCss({
path: `/src/app.${extension}`,
async style({ postcss }) {
const imports = ["utilities", "base", "elements", "form", "components", "grid", "helpers", "layout"];
imports.reverse();
const [stylesHintComment] = postcss.nodes.filter((node) => node.type === "comment" && node.text === stylesHint);
for (const import_ of imports) {
const importAtRule = new AtRule({
name: "import",
params: `"bulma/sass/${import_}/_all"`,
});
if (stylesHintComment) {
stylesHintComment.after(importAtRule);
} else {
postcss.prepend(importAtRule);
}
}
const importHint = new Comment({
text: "Import only what you need from Bulma",
});
if (stylesHintComment) {
stylesHintComment.after(importHint);
} else {
postcss.prepend(importHint);
}
return {
postcss,
};
},
});
await install({ package: "bulma" });
};