Hi Roots people!
Just quick announcement that I’ve pushed bud-wp-editor-query
to NPM.
This is a Bud extension based on an idea @strarsis put forward for splitting out FSE / Gutenberg editor styles from your main bundle, and builds on a prototype I put together earlier in the year.
With the extension installed, you can now use a media query to split your CSS into an ./editor/<module>.css
file, which can then be enqueued via add_editor_style()
.
This is can be useful when applying a theme to the block editor. For example:
@media all, (wp-editor) {
/* Style is in both main and editor CSS */
.your-styles-here {
color: blue;
}
}
@media (wp-editor) {
/* Style is ONLY in editor CSS */
.your-styles-here {
color: blue;
}
}
And then enqueue it on the editor with Sage:
add_action('after_setup_theme', function () {
$relAppCssPath = asset('editor/app.css')->relativePath(get_theme_file_path());
add_editor_style($relAppCssPath);
});
Feedback / bug reports and other contributions are greatly appreciated.
Many thanks to @strarsis and @kellymears for their input.