10
10
namespace Symfony \WebpackEncoreBundle \DependencyInjection ;
11
11
12
12
use Symfony \Component \Config \FileLocator ;
13
- use Symfony \Component \DependencyInjection \ContainerBuilder ;
14
- use Symfony \Component \DependencyInjection \Loader \XmlFileLoader ;
15
- use Symfony \Component \HttpKernel \DependencyInjection \Extension ;
16
13
use Symfony \Component \DependencyInjection \Compiler \ServiceLocatorTagPass ;
14
+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
17
15
use Symfony \Component \DependencyInjection \Definition ;
16
+ use Symfony \Component \DependencyInjection \Loader \XmlFileLoader ;
18
17
use Symfony \Component \DependencyInjection \Reference ;
18
+ use Symfony \Component \HttpKernel \DependencyInjection \Extension ;
19
19
use Symfony \WebpackEncoreBundle \Asset \EntrypointLookup ;
20
20
21
21
final class WebpackEncoreExtension extends Extension
@@ -29,13 +29,13 @@ public function load(array $configs, ContainerBuilder $container)
29
29
$ config = $ this ->processConfiguration ($ configuration , $ configs );
30
30
31
31
$ factories = [
32
- '_default ' => $ this ->entrypointFactory ($ container , '_default ' , $ config ['output_path ' ]),
32
+ '_default ' => $ this ->entrypointFactory ($ container , '_default ' , $ config ['output_path ' ], $ config [ ' cache ' ] ),
33
33
];
34
34
$ cacheKeys = [
35
35
'_default ' => $ config ['output_path ' ].'/entrypoints.json ' ,
36
36
];
37
37
foreach ($ config ['builds ' ] as $ name => $ path ) {
38
- $ factories [$ name ] = $ this ->entrypointFactory ($ container , $ name , $ path );
38
+ $ factories [$ name ] = $ this ->entrypointFactory ($ container , $ name , $ path, $ config [ ' cache ' ] );
39
39
$ cacheKeys [rawurlencode ($ name )] = $ path ;
40
40
}
41
41
@@ -46,10 +46,10 @@ public function load(array $configs, ContainerBuilder $container)
46
46
->replaceArgument (0 , ServiceLocatorTagPass::register ($ container , $ factories ));
47
47
}
48
48
49
- private function entrypointFactory (ContainerBuilder $ container , string $ name , string $ path ): Reference
49
+ private function entrypointFactory (ContainerBuilder $ container , string $ name , string $ path, bool $ cacheEnabled ): Reference
50
50
{
51
51
$ id = sprintf ('webpack_encore.entrypoint_lookup[%s] ' , $ name );
52
- $ arguments = [$ path .'/entrypoints.json ' , new Reference ('webpack_encore.cache ' ), $ name ];
52
+ $ arguments = [$ path .'/entrypoints.json ' , $ cacheEnabled ? new Reference ('webpack_encore.cache ' ) : null , $ name ];
53
53
$ container ->setDefinition ($ id , new Definition (EntrypointLookup::class, $ arguments ));
54
54
55
55
return new Reference ($ id );
0 commit comments