33
44namespace ViteHelper \Utilities ;
55
6+ use Cake \Core \Plugin ;
67use ViteHelper \Exception \ManifestNotFoundException ;
78
89/**
@@ -14,13 +15,17 @@ class ViteManifest
1415 * Returns the manifest records as a Collection
1516 *
1617 * @param \ViteHelper\Utilities\ViteHelperConfig $config plugin config instance
17- * @return \ViteHelper\Utilities\ManifestRecords|\ViteHelper\Utilities\ManifestRecord[]
18+ * @return \ViteHelper\Utilities\ManifestRecords|array< \ViteHelper\Utilities\ManifestRecord>
1819 * @throws \ViteHelper\Exception\ManifestNotFoundException
1920 * @internal
2021 */
2122 public static function getRecords (ViteHelperConfig $ config ): ManifestRecords
2223 {
23- $ manifestPath = $ config ->read ('build.manifest ' , ConfigDefaults::BUILD_MANIFEST );
24+ if ($ config ->read ('plugin ' ) && $ config ->read ('build.manifest ' ) === null ) {
25+ $ manifestPath = static ::getPluginManifestPath ($ config ->read ('plugin ' ));
26+ } else {
27+ $ manifestPath = $ config ->read ('build.manifest ' , ConfigDefaults::BUILD_MANIFEST );
28+ }
2429
2530 if (!is_readable ($ manifestPath )) {
2631 throw new ManifestNotFoundException (
@@ -29,7 +34,7 @@ public static function getRecords(ViteHelperConfig $config): ManifestRecords
2934 }
3035
3136 // phpcs:ignore
32- $ json = @file_get_contents ($ manifestPath );
37+ $ json = @file_get_contents ($ manifestPath );
3338
3439 if ($ json === false ) {
3540 throw new ManifestNotFoundException ('Could not parse manifest.json ' );
@@ -68,4 +73,9 @@ public static function getRecords(ViteHelperConfig $config): ManifestRecords
6873
6974 return new ManifestRecords ($ manifestArray , $ manifestPath );
7075 }
76+
77+ protected static function getPluginManifestPath (string $ pluginName ): string
78+ {
79+ return Plugin::path ($ pluginName ) . 'webroot ' . DS . 'manifest.json ' ;
80+ }
7181}
0 commit comments