I’m encountering an issue where my styles aren’t loading properly within Gutenberg in my local development environment. Interestingly, in production, the styling works as expected.
Yes - been suffering this for a while. You have to run the build script or the editor styles just don’t load - this is since the editor was wrapped in an iframe.
I just fixed the issue. @strarsis got me in the right direction. The issue was the http request.
I used to setup my css like add_editor_style(asset('styles/main.css')->uri());. Which using laravel mix, just retrieves the url. Which works great, but not in every enviroment.
I now changed it to add_editor_style(str_replace(get_template_directory(), '', asset('styles/main.css')->path())); which basically is the stylesheet path relative from my theme directory.
This makes sure WP takes the file from the file system, which fixes the issue.
I’m suffering this issue as well. Tailwind stylesheet not carrying over to editor, as well as any blocks targeted from app.css. Running lando npm run build applies the styles. They get undone as soon as I run lando npm run dev (I’m not sure lando has anything to do with it)
// https://discourse.roots.io/t/editor-styles-not-loading-in-wp6-3-with-bud-dev/25783/7
// No effect
// theme/app/setup.php
add_action('enqueue_block_assets', function () {
if(is_admin()) {
bundle('editor')->enqueue();
}
}, 100);
// theme/app/setup.php
add_action('after_setup_theme', function () {
add_theme_support('editor-styles');
// From the [sage docs](https://roots.io/sage/docs/gutenberg/).
// No effect
add_editor_style(asset('app.css')->relativePath(get_theme_file_path()));
// From this thread. // No effect
add_editor_style(str_replace(get_template_directory(), '', asset('styles/main.css')->path()));
// From this thread. // No effect. Is bud using laravel mix?
$relAppCssPath = asset('app.css')->relativePath(get_theme_file_path());
add_editor_style($relAppCssPath);
});