Greetings to all. I’m trying to figure out how to use the enqueue () function from ACF Composer (GitHub - Log1x/acf-composer: Compose ACF Fields, Blocks, Widgets, and Option Pages with ACF Builder on Sage 10).
I’m using Sage10 with Bud.
I have defined scripts in bud.config.js like that:
/**
* @typedef {import('@roots/bud').Bud} bud
*
* @param {bud} app
*/
module.exports = async (app) => {
app
/**
* Application entrypoints
*
* Paths are relative to your resources directory
*/
.entry({
app: ["@scripts/app", "@styles/app"],
logoSlider: ["@scripts/logoSlider", "@styles/logoSlider"],
editor: ["@scripts/editor", "@styles/editor"],
})
/**
* These files should be processed as part of the build
* even if they are not explicitly imported in application assets.
*/
.assets("images")
/**
* These files will trigger a full page reload
* when modified.
*/
.watch("resources/views/**/*", "app/**/*")
/**
* Target URL to be proxied by the dev server.
*
* This should be the URL you use to visit your local development server.
*/
.proxy("http://local.test")
/**
* Development URL to be used in the browser.
*/
.serve("http://0.0.0.0:3000");
};
Then in the block I try to add logoSlider as follows:
/**
* Assets to be enqueued when rendering the block.
*
* @return void
*/
public function enqueue()
{
//
wp_enqueue_style('slick-slider-css', 'https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.css', array(), null, 'all');
wp_enqueue_script('slick-slider-js', 'https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js', array('jquery'), null, true);
add_action('enqueue_block_editor_assets', function () {
enqueueJs('logoSlider');
}, 100);
}
I also tried command enque() to load the whole bundle, but CSS doesn’t load either.
I have one more question on this matter. If I have two blocks that use the same CSS and JS package from npm packages. The result of this should be that for the first block the whole bundle with CSS and JS is loaded together with its own JS file and for the second block only the last own JS, because the CSS and JS bundles will be loaded on the page from the previous block. ( For example, I have two blocks that use a slick slider)
Thank you so much for any help.