Skip to content
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

Embedding Editor Style (add_editor_style) during development #1171

Open
lnilya opened this issue Dec 26, 2020 · 2 comments
Open

Embedding Editor Style (add_editor_style) during development #1171

lnilya opened this issue Dec 26, 2020 · 2 comments

Comments

@lnilya
Copy link

lnilya commented Dec 26, 2020

Hi there,

I am experimenting with WPack.io and so far love the speed, it solved a lot of my build chain issues I had previously! thanks for this amazing work.

My question is what would be the best workflow to use editor-styles during development (because CSS files are not generated and Wordpress wants a CSS file).

Normally I would just embed my main CSS file via something like this: add_editor_style( 'assets/css/theme.css' ); but I can only do this when the theme/plugin was actually built, since only then I have the files.

Right now I am just adding a new entry point that embeds the css file via the Wordpress 'enqueue_block_editor_assets' hook. This way I get the style in the backend in the block editor only, however the styles of course apply to the whole site, that means all the Wordpress buttons and h1/h2 tags etc get styled as well, not only the ones inside the block editor as it would be when using add_editor_style.

Does the WPackio\Enqueue class have some sort of functionality to enable this? Or are there any workarounds for this? Getting hot reloading in the Wordpress block editor would be absolutely stellar!

Thanks a lot!

@lnilya lnilya changed the title Embedding Editor Assets during development Embedding Editor Style (add_editor_style) during development Dec 26, 2020
@lnilya
Copy link
Author

lnilya commented Dec 26, 2020

Just maybe a bit of explanation - I am using ACF Blocks, so the blocks are all server rendered in php and not embedded via JS.

@lnilya
Copy link
Author

lnilya commented Dec 28, 2020

So far the workaround I have works pretty well. Have created 2 scss files one is for the backend and one is for the frontend. They only differ in the the fact that in the backend everything goes into block-editor__typewriter and is thus limited to the editor itself.
while "imports.scss" contains the actual css code.

This obviously fails for things where you need to reference body or html (menus, popups etc)... but these styles you usually don't need in the editor anyway.

// In backend_theme.scss
.block-editor__typewriter{
	@import "imports";
}
// In frontend_theme.scss
@import "imports";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant