@@ -144,6 +144,62 @@ functions to specify which build to use:
144144 {{ encore_entry_script_tags('mobile', null, 'secondConfig') }}
145145 {{ encore_entry_link_tags('mobile', null, 'secondConfig') }}
146146
147+ Avoid Missing CSS When Rendering Multiple Templates
148+ ---------------------------------------------------
149+
150+ When you render two or more templates in the same request, such as two emails,
151+ you should call the ``reset() `` method on the ``EntrypointLookupInterface `` interface.
152+ To do this, inject the ``EntrypointLookupInterface `` interface::
153+
154+ public function __construct(EntrypointLookupInterface $entryPointLookup) {}
155+
156+ public function send() {
157+ $this->twig->render($emailOne);
158+ $this->entryPointLookup->reset();
159+ $this->render($emailTwo);
160+ }
161+
162+ If you are using multiple Webpack configurations (e.g. one for the admin and one
163+ for emails) you will need to inject the right ``EntrypointLookupInterface `` service.
164+ Use the following command to find the right service:
165+
166+ .. code-block :: terminal
167+
168+ $ php bin/console console debug:container entrypoint_lookup
169+
170+ # You will see a result similar to this:
171+ Select one of the following services to display its information:
172+ [0] webpack_encore.entrypoint_lookup_collection
173+ [1] webpack_encore.entrypoint_lookup.cache_warmer
174+ [2] webpack_encore.entrypoint_lookup[_default]
175+ [3] webpack_encore.entrypoint_lookup[admin]
176+ [4] webpack_encore.entrypoint_lookup[email]
177+
178+ In this example, the configuration related to the ``email `` configuration is
179+ the one called ``webpack_encore.entrypoint_lookup[email] ``.
180+
181+ To inject this service into your class, use the ``bind `` option:
182+
183+ .. code-block :: yaml
184+
185+ # config/services.yaml
186+ services :
187+ _defaults
188+ bind :
189+ Symfony\WebpackEncoreBundle\Asset\EntrypointLookupInterface $entryPointLookupEmail : ' @webpack_encore.entrypoint_lookup[email]'
190+
191+ Now you can inject your service into your class:
192+
193+ .. code-block :: php
194+
195+ public function __construct(EntrypointLookupInterface $entryPointLookupEmail) {}
196+
197+ public function send() {
198+ $this->twig->render($emailOne);
199+ $this->entryPointLookupEmail->reset();
200+ $this->render($emailTwo);
201+ }
202+
147203 Generating a Webpack Configuration Object without using the Command-Line Interface
148204----------------------------------------------------------------------------------
149205
0 commit comments