Skip to content

Commit 488c274

Browse files
committed
bug #51 Builds cache keys are improperly composed (webhdx, weaverryan)
This PR was squashed before being merged into the master branch (closes #51). Discussion ---------- Builds cache keys are improperly composed Looks like ba327cd has an issue with `builds` configuration. I have my app configures to use multiple builds: ```yaml webpack_encore: output_path: "%kernel.project_dir%/web/assets/build" builds: custom_build: "%kernel.project_dir%/web/assets/custom_build/build" ``` which was failing on `cache:clear`: ``` In EntrypointLookup.php line 111: [InvalidArgumentException] There was a problem JSON decoding the "/Users/maciejkobus/Projects/ezplatform/web/assets/custom_build/build" file ``` To my understanding it is trying to parse directory as a JSON and indeed it looks like cache keys are improperly combined in the Extension class. Commits ------- 7f6e111 Merge branch 'master' into multiple_builds_cache_keys b22f685 Fixed issue with invalid cache keys for builds
2 parents 80e71d8 + 7f6e111 commit 488c274

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/DependencyInjection/WebpackEncoreExtension.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
final class WebpackEncoreExtension extends Extension
2222
{
23+
private const ENTRYPOINTS_FILE_NAME = 'entrypoints.json';
24+
2325
public function load(array $configs, ContainerBuilder $container)
2426
{
2527
$loader = new XmlFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
@@ -32,11 +34,11 @@ public function load(array $configs, ContainerBuilder $container)
3234
'_default' => $this->entrypointFactory($container, '_default', $config['output_path'], $config['cache']),
3335
];
3436
$cacheKeys = [
35-
'_default' => $config['output_path'].'/entrypoints.json',
37+
'_default' => $config['output_path'].'/'.self::ENTRYPOINTS_FILE_NAME,
3638
];
3739
foreach ($config['builds'] as $name => $path) {
3840
$factories[$name] = $this->entrypointFactory($container, $name, $path, $config['cache']);
39-
$cacheKeys[rawurlencode($name)] = $path.'/entrypoints.json';
41+
$cacheKeys[rawurlencode($name)] = $path.'/'.self::ENTRYPOINTS_FILE_NAME;
4042
}
4143

4244
$container->getDefinition('webpack_encore.entrypoint_lookup.cache_warmer')
@@ -49,7 +51,7 @@ public function load(array $configs, ContainerBuilder $container)
4951
private function entrypointFactory(ContainerBuilder $container, string $name, string $path, bool $cacheEnabled): Reference
5052
{
5153
$id = sprintf('webpack_encore.entrypoint_lookup[%s]', $name);
52-
$arguments = [$path.'/entrypoints.json', $cacheEnabled ? new Reference('webpack_encore.cache') : null, $name];
54+
$arguments = [$path.'/'.self::ENTRYPOINTS_FILE_NAME, $cacheEnabled ? new Reference('webpack_encore.cache') : null, $name];
5355
$container->setDefinition($id, new Definition(EntrypointLookup::class, $arguments));
5456

5557
return new Reference($id);

0 commit comments

Comments
 (0)