1010namespace Symfony \WebpackEncoreBundle \Twig ;
1111
1212use Psr \Container \ContainerInterface ;
13+ use Symfony \WebpackEncoreBundle \Asset \EntrypointLookup ;
1314use Symfony \WebpackEncoreBundle \Asset \EntrypointLookupInterface ;
1415use Symfony \WebpackEncoreBundle \Asset \TagRenderer ;
1516use Twig \Extension \AbstractExtension ;
@@ -31,6 +32,8 @@ public function getFunctions()
3132 new TwigFunction ('encore_entry_css_files ' , [$ this , 'getWebpackCssFiles ' ]),
3233 new TwigFunction ('encore_entry_script_tags ' , [$ this , 'renderWebpackScriptTags ' ], ['is_safe ' => ['html ' ]]),
3334 new TwigFunction ('encore_entry_link_tags ' , [$ this , 'renderWebpackLinkTags ' ], ['is_safe ' => ['html ' ]]),
35+ new TwigFunction ('encore_disable_file_tracking ' , [$ this , 'disableReturnedFileTracking ' ]),
36+ new TwigFunction ('encore_enable_file_tracking ' , [$ this , 'enableReturnedFileTracking ' ]),
3437 ];
3538 }
3639
@@ -58,6 +61,27 @@ public function renderWebpackLinkTags(string $entryName, string $packageName = n
5861 ->renderWebpackLinkTags ($ entryName , $ packageName , $ entrypointName );
5962 }
6063
64+ public function disableReturnedFileTracking (string $ entrypointName = '_default ' )
65+ {
66+ $ this ->changeReturnedFileTracking (false , $ entrypointName );
67+ }
68+
69+ public function enableReturnedFileTracking (string $ entrypointName = '_default ' )
70+ {
71+ $ this ->changeReturnedFileTracking (true , $ entrypointName );
72+ }
73+
74+ private function changeReturnedFileTracking (bool $ isEnabled , string $ entrypointName )
75+ {
76+ $ lookup = $ this ->getEntrypointLookup ($ entrypointName );
77+
78+ if (!$ lookup instanceof EntrypointLookup) {
79+ throw new \LogicException ('In order to use encore_disable_returned_file_tracking/encore_enable_returned_file_tracking, the EntrypointLookupInterface must be an instance of EntrypointLookup. ' );
80+ }
81+
82+ $ lookup ->enableReturnedFileTracking ($ isEnabled );
83+ }
84+
6185 private function getEntrypointLookup (string $ entrypointName ): EntrypointLookupInterface
6286 {
6387 return $ this ->container ->get ('webpack_encore.entrypoint_lookup_collection ' )
0 commit comments