Hey thanks for all the hard work getting sage 10 + bud + acorn out the door really impressive!
I might be going about this all wrong? Hoping someone can point me in the right direction.
How would I add a directory of scss files to the Bud config to compile into separate CSS files (that will be enqueued by ACF Composer)? In pre-bud sage we have this in our Mix config:
ahah! I realised I was just missing a dot ./ in my relative styles path will post what I have in a sec in case it helps anyone or if anyone can improve on it
// app/Blocks/ExampleBlock.php
...
public function enqueue() {
bundle('example-block')->enqueue();
}
Couldn’t seem to get the alias @styles/blocks/**/[^_]*.scss to work with glob, guessing there’s some bud magic behind the scenes, but the relative path seems to work - any/all suggestions on how to tidy this up always appreciated
Edit: converted the blockStyleFiles array → object for the files to compile out separately + added enqueue snippet for ACF Block
I would like to have the same structure and I was wondering how you achieved this in combination with acf-composer, or are you not using that?
Since it expects the block template to be in /resources/views/blocks?
Should I use the $view variable or the render function?
The latter results in an error:
# Declaration of App\Blocks\MyBlock::render() must be compatible with Log1x\AcfComposer\Block::render($block, $content = '', $preview = false, $post_id = 0)
I think Kelly was referring to a vanilla structure for blocks. What are you trying to achieve? Moving the blocks folder outside of views/? Right now it will always expect them to be in views/ because that’s what Laravel’s view() function defaults to.
For putting them inside of a folder you should be able to set the $view property to e.g. blocks.block-a.index to look for index.blade.php inside of the resources/views/block-a folder.
I think my goal is/was to have a separate folder for each ACF block in the resources folder, containing it’s own blade template, script & style files, instead of spreading those around in the views, scripts & styles folders.
If Laravel expects the block template to be in the views folder (which I understand completely), then it already defeats this purpose.
aha! this was the missing piece of the puzzle for us, we’ve got all assets in their own folders but views were always left in views/blocks/* - going to have a play with $view
Semi-related, wondering if it’d be nicer to move each block (views + assets) to a plugin?
This is technically already possible (unless it got broken at some point) but I haven’t actually used the implementation myself on production so it’s not battle tested or mentioned anywhere.
I will try to get the example repo for it polished/tested and made public when I can.
Following up on this, since you’re also the creator of the marvellous log1x/poet
Would it also be possible to set the location of the block view in the poet registering a block functionality, similar to the $view variable in log1x/acf-composer?
config/poet.php:
return [
'block' => [
'domain/native-block'
],
];
That way I can truly have this structure for native & acf blocks: