Hi guys
I found a trick to include the front style in Gutenberg editor :
- Copy the style from your
app.css
file to theeditor.css
file (with a simple configuration, an @import should be enough). In my case I use tailwind, I copy/paste the whole file with all imports. - Add the
postcss-prefixwrap
plugin. Use eitherpostcss.config.js
(tested) orbud.config.js
(not tested). Set.editor-styles-wrapper
as prefix. - Make sure that the plugin is only executed on the
editor.css
file : frompostcss.config.js
, just check if the name of the processed file contains editor.css.
Ex:
module.exports = (api) => {
return {
ident: 'postcss',
plugins: getPlugins(api.file.includes('/editor.css')),
};
};
- Disable the default editor’s styles
add_action('after_setup_theme', function () {
remove_editor_styles();
}, 999);
And it’s done !