Closed rpayanm closed 2 years ago
Hi there!
This, is obviously a bit tricky to get wired up :). The problematic part is:
webpack_encore.entrypoint_lookup_collection:
class: Symfony\WebpackEncoreBundle\Asset\EntrypointLookupCollection
arguments:
['@service_container']
The 1st argument - ContainerInterface $buildEntrypoints
- isn't referring to the "main" service container, but to a "mini" container locator that contains your "EntrypointLookup services". https://symfony.com/doc/current/service_container/service_subscribers_locators.html#defining-a-service-locator
I believe you would need something like this:
webpack_encore.default_entrypoint:
class: Symfony\WebpackEncoreBundle\Asset\EntrypointLookup
arguments:
- 'path/to/entrypoints.json'
webpack_encore.entrypoint_lookup_collection:
class: Symfony\WebpackEncoreBundle\Asset\EntrypointLookupCollection
arguments:
- !service_locator
_default: '@webpack_encore.default_entrypoint'
Good luck!
Hi, @weaverryan thank you! But I got this new error:
In YamlSymfony.php line 40:
Tags support is not enabled. You must use the flag "Yaml::PARSE_CUSTOM_TAGS" to use "!service_locator" at line 27 (near "!service_locator").
In Parser.php line 1157:
Tags support is not enabled. You must use the flag "Yaml::PARSE_CUSTOM_TAGS" to use "!service_locator" at line 27 (near "!service_locator").
Hmm. I'm not sure if there is any other way to define this in YAML. You could try to create (I can't remember what it's called in Drupal) a PHP config where you define these services (instead of YAML), but it still tricky. This is, unfortunately, a spot where Drupal and Symfony differ a bit.
My best advice would be to "steal" from this bundle. Parsing the entrypoints.json
is actually pretty simple. We've added a lot of "bells and whistles", but at the end of the day, we're effectively just parsing that JSON file and using it with the encore_entry...()
functions.
Cheers!
ok @weaverryan I will do that, thank you for your support!
I would like to use this bundle in Drupal, is any way to do it?
I create a module and in my *.services.yml file, inside I have:
I installed this module, but I got this error: