-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scripts: npm run start does not load refreshed stylesheet into editor-canvas iframe, only head of main document #48448
Comments
Hi, |
+1 |
If you run There are 2 other more developer friendly option you could implement which is: 1) your own This might help #28273 |
Hi, |
As @Supportic mentioned above, you will need to clear the cache occasionally or follow one of the suggestions posted above. I personally use I am going to close out this issue, but please feel free to reopen if you are experiencing any additional issues. |
The frontend styles/scripts regenerate a version number on every file change (via the assets PHP file) which automatically busts the cache. The admin should have the same. It's a pain to clear the cache while developing the admin side. Please consider reopening. |
@helgatheviking of course, happy to reopen. |
To me it looks it's already loading The real issue here seems to be that it's loading the Might be caused by not externalizing react-refresh. It's mentioned the troubleshooting there and it's also some more information in this issue. |
It is externalized. That's necessary for making it work with the way WordPress enqueues scripts.
That sounds very likely to happen. I would recommend exploring that path further 👍 |
Yea, I debugged it in the inspector yesterday and observed that everything worked and change of index.scss trigged a full css reload, except I found the newly loaded correct style in the of the document and the initial loaded style was still there in the iframe. So pretty sure this is the issue. |
Maybe a result of the externalization then? pmmmwh/react-refresh-webpack-plugin#743 |
Just ran into this issue again a year later. Is there anything I can do to nudge this along. I'm new to block dev, and having to clear the cache on my browser (which logs me out of my dev site) in order to test changes to editor styles is a very annoying barrier. |
I looked a bit more into the issue, but couldn't find a way around it. Seems rather tricky. Think wp-scripts need to have an insert function for But the insert function doesn't run because it can't find the chunkId and there are even testcases on Could also be possible to just have a hack in your plugin that clones the link tags. I'm sure some block developers have fixed this somehow already as everyone developing using create-block can't be sitting reloading the page all the time, I hope 😕 Would also be good if someone changed the title of this bug. Should be something like: "npm run start does not load refreshed stylesheet into editor-canvas iframe, only head of main document" |
What problem does this address?
I created an example block plugin via
npx @wordpress/scripts create-block
then I changed into the new directory and ran
npm run start
I added my new sample block into the editor to start playing around with it. And I noticed that the text was illegible due to inaccessible colors (dark gray text on a gray blue background)
I made a change to
src/style.scss
and the stylesheet was re-compiled.But when I refreshed the editor page, nothing happened. In source the stylesheet still has a version of
0.1
which appears to be the style set inblock.json
as there's noenqueue_block_editor_assets
anywhere to enqueue assets. Updating the version inblock.json
finally forces the browser to refresh the stylesheet.If that's intended behavior it's very counter to what I think
npm run start
is meant to do... put you in a developmental mode where everything updates as soon as you make a change..... even more so if you are attemptingnpm run start --hot
and expecting hot reloading.What is your proposed solution?
npm run start
should enqueue a stylesheet based on the time it was last compiled... which I believe can already be found inbuild/index.asset.php
and I as far as I can tell is used for the javascript files (as a change insrc/edit.js
) is immediately shown in the editor.The text was updated successfully, but these errors were encountered: