2

I would like to add include additional script handles to the dependencies in assets.php using @wordpress/dependency-extraction-webpack-plugin.

An example for this would be a script that extends masonry which is a script that is included and registered by WordPress.

6
  • this is usually documented as a part of WP Scripts usage rather than that particular package
    – Tom J Nowell
    Commented Apr 13, 2021 at 9:27
  • Sorry, I don't follow 🤔
    – grappler
    Commented Apr 13, 2021 at 9:46
  • 1
    people rarely use that package you linked to directly. Instead they use the WP Scripts package, which uses the extraction plugin as a dependency. If you look for documentation to do this in the extraction package, you won't find it because it's documented on the WP Scripts package in the handbook
    – Tom J Nowell
    Commented Apr 13, 2021 at 9:58
  • Also what you're wanting to do is already documented on the page you linked to via requestToExternal and requestToHandle, you should be able to rename my module to masonry from the 2 examples.
    – Tom J Nowell
    Commented Apr 13, 2021 at 10:01
  • Thanks, yea, I am using the extraction package as part of @wordpress/scripts. So you are saying that something like this should work: gist.github.com/grappler/d1b226565d8efb24cbadefe2712f3d15 What I am unsure about is how the import in my file should be and if masonry needs to be part of the package.json
    – grappler
    Commented Apr 13, 2021 at 13:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.