diff --git a/install/package.json b/install/package.json index db25576..0c24eb8 100644 --- a/install/package.json +++ b/install/package.json @@ -6,7 +6,7 @@ }, "license": "UNLICENSED", "devDependencies": { - "vite": "~2.9", - "vite-plugin-symfony": "^0.3.0" + "vite": "^3.0", + "vite-plugin-symfony": "^0.4.0" } } \ No newline at end of file diff --git a/src/Asset/ViteAssetVersionStrategy.php b/src/Asset/ViteAssetVersionStrategy.php index 5ce5af0..e808613 100644 --- a/src/Asset/ViteAssetVersionStrategy.php +++ b/src/Asset/ViteAssetVersionStrategy.php @@ -11,7 +11,6 @@ class ViteAssetVersionStrategy implements VersionStrategyInterface { private string $entrypointsPath; private array $entrypointsData; - private string $assetsPath; private ?array $assetsData = null; private bool $strictMode; @@ -19,10 +18,9 @@ class ViteAssetVersionStrategy implements VersionStrategyInterface * @param string $entrypointsPath Absolute path to the entrypoints file * @param bool $strictMode Throws an exception for unknown paths */ - public function __construct(string $entrypointsPath, string $assetsPath, bool $strictMode = true) + public function __construct(string $entrypointsPath, bool $strictMode = true) { $this->entrypointsPath = $entrypointsPath; - $this->assetsPath = $assetsPath; $this->strictMode = $strictMode; if (($scheme = parse_url($this->entrypointsPath, \PHP_URL_SCHEME)) && 0 === strpos($scheme, 'http')) { @@ -57,19 +55,11 @@ private function getassetsPath(string $path): ?string } catch (\JsonException $e) { throw new RuntimeException(sprintf('Error parsing JSON from entrypoints file "%s": ', $this->entrypointsPath) . $e->getMessage(), previous: $e); } - - if (is_file($this->assetsPath)) { - try { - $this->assetsData = json_decode(file_get_contents($this->assetsPath), true, flags: \JSON_THROW_ON_ERROR); - } catch (Exception $e) { - throw new RuntimeException(sprintf('Error parsing JSON from assets file "%s": ', $this->assetsPath) . $e->getMessage(), previous: $e); - } - } } if ($this->entrypointsData['isProd']) { - if (isset($this->assetsData[$path])) { - return $this->assetsData[$path]; + if (isset($this->entrypointsData['assets'][$path])) { + return $this->entrypointsData['assets'][$path]; } } else { return $this->entrypointsData['viteServer']['origin'] . $this->entrypointsData['viteServer']['base'] . $path; diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 56c4e66..7aad677 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -20,7 +20,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->addDefaultsIfNotSet() ->children() ->scalarNode('host')->defaultValue('localhost')->end() - ->integerNode('port')->defaultValue(3000)->end() + ->integerNode('port')->defaultValue(5173)->end() ->booleanNode('https')->defaultFalse()->end() ->end() ->end() diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml index ae289c2..b7821b1 100644 --- a/src/Resources/config/services.yaml +++ b/src/Resources/config/services.yaml @@ -39,5 +39,4 @@ services: Pentatrion\ViteBundle\Asset\ViteAssetVersionStrategy: arguments: - "%kernel.project_dir%/public%pentatrion_vite.base%entrypoints.json" - - "%kernel.project_dir%/public%pentatrion_vite.base%assets.json" - true \ No newline at end of file