How to get setup with editor styling for the classic editor with Sage 10 + Bud?

Anyone managed to get Sage 10 with Bud + editor styling for TinyMCE to work? Would appreciate tips on how to get it going.


    app: ['@scripts/app', '@styles/app'],
    editor: ['@scripts/editor', '@styles/editor'],
    tinymce: ['@styles/tinymce'],


  $asset = \Roots\asset('tinymce.css');

Gives me
Refused to apply style from 'http://domain.test/app/themes/theme/public/tinymce.css?wp-mce-49110-20201110' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Same thing happens if I try:
$asset = \Roots\asset('css/tinymce.css'); which is the folder where the artifact gets built on yarn build

Edit: The warning indicates that the URI to the stylesheet is not found, rather a soft-404 HTML page is retrieved.

How is that site hosted? Development, with a VM or container? Production?
When you request the stylesheet URL from within the system where PHP-FPM runs, do you get a stylesheet or rather a soft 404 error page (HTML)?
curl http://domain.test/app/themes/theme/public/tinymce.css?wp-mce-49110-20201110

Have you updated the theme-path in the bud configuration so that it matches the actual path the theme is in (including the theme folder name)?

As a workaround (rather a dirty fix, as core and plugins often rely on a functioning loopback connection and the theme URI should be correct for the assets) you can add the editor styles by relative path than by URI, which does not need a loopback connection:

Hey, thanks for the quick reply!

It’s a project scaffolded yesterday, using Trellis with Lima. And yes, I’m getting a 404 on that URL form within the VM (Should there be a file generated without random hash at the end? Because there is no file like that).

Theme path should be alright:

I’ll look into your suggestion for a work around :slight_smile:

Can you request a page / start page of the site? What is its URL then (after letting WordPress redirect)? Just http://domain.test?

The random hash at the end (tinymce.css?wp-mce-49110-20201110) is used for cache-busting as it is not a part of the file name, but rather a GET-parameter, which normally should not matter for static files.

Yes, correct.

Should add that everything else works as expected, app.css, fonts and images stored in resources works fine both on localhost:3000 and domain.test.

Can you invoke commands from within the Lima VM/system? Because from within that system the domain domain.test must be resolvable and the server must listen for and answer requests from the VM IP (e.g.

What do you mean by commands? I can curl domain.test and I get the content of the front page just fine.

PHP-FPM (which does run WordPress) itself does the HTTP request, inside the Lima VM.
The request results in a HTML response, not in the frontend styles file.
For diagnosing the issue you have to do the request from inside the Lima VM to see how the web server responses.

Ah :slight_smile: If I do trellis vm shell and run curl domain.test it does return the actual front page, and not a 404 page.

Both curl http://domain.test/app/themes/theme/public/css/app.d8aefd.css and
curl http://domain.test/app/themes/theme/public/css/tinymce.1fc2a8.css shows the content of the files.

But should I use $asset = \Roots\asset('tinymce.css') or $asset = \Roots\asset('css/tinymce.css')? Sans the prefixed path it looks at http://domain.test/app/themes/theme/public/tinymce.css?wp-mce-49110-20201110, which obviously is empty.

Are you using this?:

What URL do you get with echo asset('app.css')->__toString()?

add_action('after_setup_theme', function () {

Gets me the same mime error.

add_action('after_setup_theme', function () {
  $relAppCssPath = asset('tinymce.css')->relativePath(get_theme_file_path());

Appears to do nothing, no error in the console, no styling applied. Not tinymce.css in network tab.

add_action('after_setup_theme', function () {
  $asset = \Roots\asset('tinymce.css');

Mime error.

Dumping what you suggested gets me:

Dumping tinymce.css gets me:

Super thankful for your time and your suggestions by the way!

Does that URL work inside the Lima VM?

Connection refused for anything on that host from the vm shell :eyes:

But the dump was made from a blade template btw, so I guess that’s why it’s localhost and not domain.test?

The URL passed to add_editor_style has localhost as domain, which is not reachable from within the Lima VM. Check the bud configuration:

Updated packages to latest version (had outdated bud and sage) and changed to the bud.config.js you lined. Issue still persist :confused:

I’m curious if maybe Lima could be the issue somehow.

Is the URL passed to add_editor_style still with localhost domain?

It is.

Got it to work now finally, when running yarn dev it does not work. Running yarn build and then accessing /wp-admin/ – then it works! :fireworks:

So yarn dev does not update the domain that is used for the asset URLs, but yarn build does?
After invoking yarn build, yarn dev works without issue?

As soon as yarn dev is run, it breaks, I need to run yarn buildon every change in tinymce.css and it will work in the editor.

Hm, upon further thought it makes sense as dev uses the proxy domain (and some free port, as this is by default localhost) instead of the original server one. Does the workaround with adding the frontend stylesheet asset by its path (instead of URL) work?

A fix of the underlying issue would probably consist of being able to retrieve the asset URL without the proxy domain and port from the manifest.