-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbud.config.ts
116 lines (104 loc) · 2.87 KB
/
bud.config.ts
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import type { Bud } from "@roots/bud";
/**
* Bud config
*/
export default async (bud: Bud) => {
bud
.proxy(`http://radicle.test`)
.serve(`http://localhost:4000`)
.watch([bud.path(`resources/views`), bud.path(`app`)])
.entry(`app`, [`@scripts/app`, `@styles/app`])
.entry(`editor`, [`@scripts/editor`, `@styles/editor`])
.copyDir(`images`)
.setPublicPath(`/dist/`)
.experiments(`topLevelAwait`, true)
.wpjson.setSettings({
color: {
custom: false,
customDuotone: false,
customGradient: false,
defaultDuotone: false,
defaultGradients: false,
defaultPalette: false,
duotone: [],
},
custom: {
spacing: {},
typography: {
"font-size": {},
"line-height": {},
},
},
layout: {
contentSize: `64rem`,
},
spacing: {
padding: true,
units: [`px`, `%`, `em`, `rem`, `vw`, `vh`],
},
typography: {
customFontSize: false,
dropCap: undefined,
},
})
.setStyles({
spacing: {
blockGap: `1.5rem`,
padding: {
left: `1.5rem`,
right: `1.5rem`,
},
},
typography: {
fontFamily: `var(--wp--preset--font-family--sans)`,
fontSize: `var(--wp--preset--font-size--normal)`,
},
})
.setPath(bud.path(`public/content/themes/radicle/theme.json`));
bud.when(`tailwind` in bud, ({ wpjson }) =>
wpjson.useTailwindColors().useTailwindFontFamily().useTailwindFontSize()
);
await bud.tapAsync(sourceThemeValues);
bud
.when(`eslint` in bud, ({ eslint }) =>
eslint
.extends([
`@roots/eslint-config/sage`,
`@roots/eslint-config/typescript`,
`plugin:react/jsx-runtime`,
])
.setFix(true)
.setFailOnWarning(bud.isProduction)
)
/**
* Stylelint config
*/
.when(`stylelint` in bud, ({ stylelint }) =>
stylelint
.extends([
`@roots/sage/stylelint-config`,
`@roots/bud-tailwindcss/stylelint-config`,
])
.setFix(true)
.setFailOnWarning(bud.isProduction)
)
/**
* Image minification config
*/
.when(`imagemin` in bud, ({ imagemin }) =>
imagemin.encode(`jpeg`, { mozjpeg: true, quality: 70 })
);
};
/**
* Find all `*.theme.js` files and apply them to the `theme.json` output
*/
const sourceThemeValues = async ({ error, glob, wpjson }: Bud) => {
const importMatching = async (paths: Array<string>) =>
await Promise.all(paths.map(async (path) => (await import(path)).default));
const setThemeValues = (records: Record<string, unknown>) =>
Object.entries(records).map((params) => wpjson.set(...params));
await glob(`resources/**/*.theme.js`)
.then(importMatching)
.then((modules) => modules.map(setThemeValues))
.catch(error);
};