Skip to content

Commit cc94b1b

Browse files
authored
bump: bud@6.12.0 & improvements (roots#3128)
This PR contains various improvements and cleanups to the configuration and JavaScript code. Key changes include: - Adding simple comments to `jsconfig.json`. - Improving config: `bud.wpjson.set` replaces `bud.wpjson.settings`. Note that `bud.wpjson.settings` is not deprecated. - `bud.wpjson.settings` now disables `dropCap` by default. - `app.js` and `editor.js` now use `if (import.meta.webpackHot)` instead of optional chaining, since `import.meta.webpackHot` is not a real method and using optional chaining might cause errors.
1 parent 102778a commit cc94b1b

File tree

8 files changed

+2393
-2047
lines changed

8 files changed

+2393
-2047
lines changed

bud.config.js

Lines changed: 50 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,64 @@
11
/**
2-
* Build configuration
2+
* Compiler configuration
33
*
4-
* @see {@link https://roots.io/docs/sage/ sage documentation}
5-
* @see {@link https://bud.js.org/guides/configure/ bud.js configuration guide}
4+
* @see {@link https://roots.io/docs/sage sage documentation}
5+
* @see {@link https://bud.js.org/guides/configure bud.js configuration guide}
66
*
7-
* @typedef {import('@roots/bud').Bud} Bud
8-
* @param {Bud} app
7+
* @param {import('@roots/bud').Bud} app
98
*/
109
export default async (app) => {
1110
/**
12-
* Application entrypoints
13-
* @see {@link https://bud.js.org/docs/bud.entry/}
11+
* Application assets & entrypoints
12+
*
13+
* @see {@link https://bud.js.org/docs/bud.entry}
14+
* @see {@link https://bud.js.org/docs/bud.assets}
1415
*/
1516
app
16-
.entry({
17-
app: ['@scripts/app', '@styles/app'],
18-
editor: ['@scripts/editor', '@styles/editor'],
19-
})
17+
.entry('app', ['@scripts/app', '@styles/app'])
18+
.entry('editor', ['@scripts/editor', '@styles/editor'])
19+
.assets(['images']);
2020

21-
/**
22-
* Directory contents to be included in the compilation
23-
* @see {@link https://bud.js.org/docs/bud.assets/}
24-
*/
25-
.assets(['images'])
26-
27-
/**
28-
* Matched files trigger a page reload when modified
29-
* @see {@link https://bud.js.org/docs/bud.watch/}
30-
*/
31-
.watch(['resources/views', 'app'])
32-
33-
/**
34-
* Proxy origin (`WP_HOME`)
35-
* @see {@link https://bud.js.org/docs/bud.proxy/}
36-
*/
37-
.proxy('http://example.test')
38-
39-
/**
40-
* Development origin
41-
* @see {@link https://bud.js.org/docs/bud.serve/}
42-
*/
43-
.serve('http://localhost:3000')
21+
/**
22+
* Set public path
23+
*
24+
* @see {@link https://bud.js.org/docs/bud.setPublicPath}
25+
*/
26+
app.setPublicPath('/app/themes/sage/public/');
4427

45-
/**
46-
* URI of the `public` directory
47-
* @see {@link https://bud.js.org/docs/bud.setPublicPath/}
48-
*/
49-
.setPublicPath('/app/themes/sage/public/')
28+
/**
29+
* Development server settings
30+
*
31+
* @see {@link https://bud.js.org/docs/bud.setUrl}
32+
* @see {@link https://bud.js.org/docs/bud.setProxyUrl}
33+
* @see {@link https://bud.js.org/docs/bud.watch}
34+
*/
35+
app
36+
.setUrl('http://localhost:3000')
37+
.setProxyUrl('http://example.test')
38+
.watch(['resources/views', 'app']);
5039

51-
/**
52-
* Generate WordPress `theme.json`
53-
*
54-
* @note This overwrites `theme.json` on every build.
55-
*
56-
* @see {@link https://bud.js.org/extensions/sage/theme.json/}
57-
* @see {@link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-json/}
58-
*/
59-
.wpjson.settings({
60-
color: {
61-
custom: false,
62-
customDuotone: false,
63-
customGradient: false,
64-
defaultDuotone: false,
65-
defaultGradients: false,
66-
defaultPalette: false,
67-
duotone: [],
68-
},
69-
custom: {
70-
spacing: {},
71-
typography: {
72-
'font-size': {},
73-
'line-height': {},
74-
},
75-
},
76-
spacing: {
77-
padding: true,
78-
units: ['px', '%', 'em', 'rem', 'vw', 'vh'],
79-
},
80-
typography: {
81-
customFontSize: false,
82-
},
83-
})
40+
/**
41+
* Generate WordPress `theme.json`
42+
*
43+
* @note This overwrites `theme.json` on every build.
44+
*
45+
* @see {@link https://bud.js.org/extensions/sage/theme.json}
46+
* @see {@link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-json}
47+
*/
48+
app.wpjson
49+
.set('settings.color.custom', false)
50+
.set('settings.color.customDuotone', false)
51+
.set('settings.color.customGradient', false)
52+
.set('settings.color.defaultDuotone', false)
53+
.set('settings.color.defaultGradients', false)
54+
.set('settings.color.defaultPalette', false)
55+
.set('settings.color.duotone', [])
56+
.set('settings.custom.spacing', {})
57+
.set('settings.custom.typography.font-size', {})
58+
.set('settings.custom.typography.line-height', {})
59+
.set('settings.spacing.padding', true)
60+
.set('settings.spacing.units', ['px', '%', 'em', 'rem', 'vw', 'vh'])
61+
.set('settings.typography.customFontSize', false)
8462
.useTailwindColors()
8563
.useTailwindFontFamily()
8664
.useTailwindFontSize()

jsconfig.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,28 @@
22
"extends": "@roots/sage/config/jsconfig.json",
33
"compilerOptions": {
44
"baseUrl": "resources",
5+
/**
6+
* Resolve aliases
7+
*/
58
"paths": {
69
"@fonts/*": ["fonts/*"],
710
"@images/*": ["images/*"],
811
"@scripts/*": ["scripts/*"],
912
"@styles/*": ["styles/*"]
1013
},
11-
"types": ["@roots/bud", "@roots/sage", "@roots/bud-tailwindcss"]
14+
/**
15+
* Type definitions
16+
*/
17+
"types": [
18+
"@roots/bud",
19+
"@roots/bud-react",
20+
"@roots/bud-postcss",
21+
"@roots/bud-preset-recommend",
22+
"@roots/bud-preset-wordpress",
23+
"@roots/bud-tailwindcss",
24+
"@roots/bud-wordpress-theme-json",
25+
"@roots/sage"
26+
]
1227
},
1328
"include": ["bud.config.js", "resources"],
1429
"exclude": ["node_modules", "public"]

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
"translate:mo": "wp i18n make-mo ./resources/lang ./resources/lang"
2020
},
2121
"devDependencies": {
22-
"@roots/bud": "6.11.0",
23-
"@roots/bud-tailwindcss": "6.11.0",
24-
"@roots/sage": "6.11.0"
25-
}
22+
"@roots/bud": "6.12.0",
23+
"@roots/bud-tailwindcss": "6.12.0",
24+
"@roots/sage": "6.12.0"
25+
},
26+
"dependencies": {}
2627
}

resources/scripts/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ domReady(async () => {
1010
/**
1111
* @see {@link https://webpack.js.org/api/hot-module-replacement/}
1212
*/
13-
import.meta.webpackHot?.accept(console.error);
13+
if (import.meta.webpackHot) import.meta.webpackHot.accept(console.error);

resources/scripts/editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ domReady(() => {
1616
/**
1717
* @see {@link https://webpack.js.org/api/hot-module-replacement/}
1818
*/
19-
import.meta.webpackHot?.accept(console.error);
19+
if (import.meta.webpackHot) import.meta.webpackHot.accept(console.error);
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// https://tailwindcss.com/docs/configuration
2-
module.exports = {
1+
/** @type {import('tailwindcss').Config} config */
2+
const config = {
33
content: ['./index.php', './app/**/*.php', './resources/**/*.{php,vue,js}'],
44
theme: {
55
extend: {
@@ -8,3 +8,5 @@ module.exports = {
88
},
99
plugins: [],
1010
};
11+
12+
export default config;

0 commit comments

Comments
 (0)