-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtailwind.js
53 lines (45 loc) · 999 Bytes
/
tailwind.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
import postcss from "npm:[email protected]";
import tailwindcss from "npm:[email protected]";
import autoprefixer from "npm:autoprefixer";
const {
readTextFile,
writeTextFile
} = Deno;
const FROM = "./tailwind.css";
const TO = "./static/style/tailwind.css";
const DEFAULT_OPTIONS = {
content: [
"./routes/**/*.jsx",
"./components/**/*.jsx",
"./islands/**/*.jsx"
],
theme: {}
};
const DEFAULT_TAILWIND_CSS = `
@tailwind base;
@tailwind components;
@tailwind utilities;
`;
/**
*
* @param partialConfig
*/
const dev = async (
partialConfig = DEFAULT_OPTIONS
) => {
const config = {
...DEFAULT_OPTIONS,
...partialConfig
};
const processor = postcss([
tailwindcss(config), autoprefixer()
// cssnano({ preset: ["default", { cssDeclarationSorter: false }] })
]);
const css = await readTextFile(FROM).catch(() => DEFAULT_TAILWIND_CSS);
const content = await processor.process(css, {
from: FROM,
to: TO
});
await writeTextFile(TO, content.css);
};
export default dev;