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

Assets - Add bock asset features to compile dependencies and version - WIP #4

Closed
wants to merge 6 commits into from

Conversation

jesseeproductions
Copy link
Contributor

@jesseeproductions jesseeproductions commented Mar 6, 2024

Adds methods to set dependencies and version based on complied block assets.

Utilize the following methods when adding an asset:
Set path automatically:

Asset::add(
	'event-schedule-manager-speaker-list-block-js',
	'js/app/speaker-list/index.js'
	)
	->set_as_compiled()
	->add_to_group( 'event-schedule-manager-editor' )
	->register();

Or set the path manually:

Asset::add(
	'event-schedule-manager-speaker-list-block-js',
	'speaker-list-block-index.js'
	)
	->set_as_compiled()
        ->set_compiled_path( 'js/app/speaker-list/index' )
	->add_to_group( 'event-schedule-manager-editor' )
	->register();

Both examples assume the default asset path is in src/resources/

@jesseeproductions jesseeproductions added the enhancement New feature or request label Mar 6, 2024
@jesseeproductions jesseeproductions self-assigned this Mar 6, 2024
Copy link
Member

@bordoni bordoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to see us simplify to allow assets to be compiled or not and then just add the compiled variables to the ones that we have set.

src/Assets/Asset.php Outdated Show resolved Hide resolved
src/Assets/Asset.php Outdated Show resolved Hide resolved
src/Assets/Asset.php Outdated Show resolved Hide resolved
@jesseeproductions
Copy link
Contributor Author

  • I updated the coding to have set_compiled_data() method that can be used to setup the asset to use the compiled data if found.
  • I did pass the src to it because the slug would have to be changed to the src and gives you less options in naming.
  • The get_version and get_dependencies are updated to use compiled data if found.

src/Assets/Asset.php Outdated Show resolved Hide resolved
src/Assets/Asset.php Outdated Show resolved Hide resolved
@jesseeproductions jesseeproductions marked this pull request as ready for review April 17, 2024 15:03
@borkweb
Copy link
Member

borkweb commented Sep 26, 2024

I'm closing this one in favor of a further evolution in #19

@borkweb borkweb closed this Sep 26, 2024
@borkweb borkweb deleted the feature/block-assets branch September 26, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants