@@ -148,6 +148,65 @@ functions to specify which build to use:
148148 {{ encore_entry_script_tags('mobile', null, 'secondConfig') }}
149149 {{ encore_entry_link_tags('mobile', null, 'secondConfig') }}
150150
151+ Avoid missing CSS when render multiples html
152+ --------------------------------------------
153+
154+ When you need to generate two templates in the same request, such as two emails, you should call the reset method on
155+ the ``EntrypointLookupInterface `` interface.
156+
157+ To do this, inject the ``EntrypointLookupInterface `` interface
158+
159+ .. code-block :: php
160+
161+ public function __construct(EntrypointLookupInterface $entryPointLookup) {}
162+
163+ public function send() {
164+ $this->twig->render($emailOne);
165+ $this->entryPointLookup->reset();
166+ $this->render($emailTwo);
167+ }
168+
169+ If you are using multiple webpack configurations, for example, one for the admin and one for emails, you will need to
170+ inject the correct ``EntrypointLookupInterface `` service. To achieve this, you should search for the service
171+ using the following command:
172+
173+ .. code-block :: terminal
174+
175+ # if you are using symfony CLI
176+ $ symfony console debug:container entrypoint_lookup
177+
178+ # You will see a result similar to this:
179+ Select one of the following services to display its information:
180+ [0] webpack_encore.entrypoint_lookup_collection
181+ [1] webpack_encore.entrypoint_lookup.cache_warmer
182+ [2] webpack_encore.entrypoint_lookup[_default]
183+ [3] webpack_encore.entrypoint_lookup[admin]
184+ [4] webpack_encore.entrypoint_lookup[email]
185+
186+ The service we are interested in is ``webpack_encore.entrypoint_lookup[email] ``.
187+
188+ To inject this service into your class, we will use the bind method:
189+
190+ .. code-block :: yaml
191+
192+ services :
193+ _defaults
194+ bind :
195+ Symfony\WebpackEncoreBundle\Asset\EntrypointLookupInterface $entryPointLookupEmail : ' @webpack_encore.entrypoint_lookup[email]'
196+
197+
198+ Now you can inject your service into your class:
199+
200+ .. code-block :: php
201+
202+ public function __construct(EntrypointLookupInterface $entryPointLookupEmail) {}
203+
204+ public function send() {
205+ $this->twig->render($emailOne);
206+ $this->entryPointLookupEmail->reset();
207+ $this->render($emailTwo);
208+ }
209+
151210 Generating a Webpack Configuration Object without using the Command-Line Interface
152211----------------------------------------------------------------------------------
153212
0 commit comments