-
Notifications
You must be signed in to change notification settings - Fork 65
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
Enqueue styles and scripts #67
Comments
@djmtype Did you find a solution? |
Here is a temporary solution. |
@yannickninot Thanks! Create the template: Added the s/css file: testimonial.blade.php
Leave Otherwise, we don't want to load the same CSS file twice – once with the hash, as will be defined in bud.config.js app.entry({
app: ['@scripts/app', '@styles/app'],
editor: ['@scripts/editor', '@styles/editor'],
testimonial: ['@styles/blocks/testimonial']
}) setup.php add_action('wp_enqueue_scripts', function () {
bundle('app')->enqueue();
if (has_block('acf/testimonial')) {
bundle('testimonial')->enqueue();
}
}, 100); |
If you want to expose those styles to the editor, you'll have to duplicate your efforts within setup.php under add_action('enqueue_block_editor_assets', function () {
bundle('editor')->enqueue();
if (has_block('acf/testimonial')) {
bundle('testimonial')->enqueue();
}
}, 100); |
I found a trick to include the front style in Gutenberg :
module.exports = (api) => {
return {
ident: 'postcss',
plugins: getPlugins(api.file.includes('/editor.css')),
};
};
add_action('after_setup_theme', function () {
remove_editor_styles();
}, 999); And it's done ! |
@djmtype Thank you for figuring it out for us. Saved us some research time and I used some of your code to enable Bud support. I made a PR #75 so we can enqueue our styles and scripts again like before, but this time by using the Bud bundle name instead of the path to file like before. Sorry for the late response. I haven't had much spare time to look into it. |
How do we properly enqueue styes and scripts with this plugin?
If I reference these files from the
dist
directory that Sage ends up building, they are appended with random characters, so that's not going to work unless this plugin understands Sage's asset handling.Or do I need to process these files in advance?
The text was updated successfully, but these errors were encountered: