@@ -19,6 +19,11 @@ class ViteAssetsLoader {
1919 */
2020 private $ manifest_data = null ;
2121
22+ /**
23+ * Path to the manifest file
24+ */
25+ private $ manifest_path ;
26+
2227 /**
2328 * URL to the manifest file
2429 */
@@ -51,12 +56,13 @@ class ViteAssetsLoader {
5156 * @param string $manifest_url url to the manifest; it's used to build production urls
5257 */
5358 public function __construct ( string $ manifest_path , string $ manifest_url ) {
59+ $ this ->manifest_path = $ manifest_path ;
5460 $ this ->manifest_url = $ manifest_url ;
5561
5662 $ hot_file_applied = $ this ->apply_hot_file_configuration ();
5763
5864 if ( ! $ hot_file_applied ) {
59- $ this ->apply_prod_manifest_configuration ( $ manifest_path );
65+ $ this ->apply_prod_manifest_configuration ();
6066 }
6167
6268 // wp_enqueue_script is the proper hook to enqueue scripts AND styles
@@ -82,7 +88,7 @@ public function __construct( string $manifest_path, string $manifest_url ) {
8288 * @return bool
8389 */
8490 protected function apply_hot_file_configuration () {
85- $ hot_file_path = APP_THEME_DIR . '.hotfile.json ' ;
91+ $ hot_file_path = dirname ( $ this -> manifest_path ) . '/ .hotfile.json ' ;
8692
8793 if ( ! file_exists ( $ hot_file_path ) ) {
8894 return false ;
@@ -120,10 +126,10 @@ protected function apply_hot_file_configuration() {
120126 *
121127 * @return void
122128 */
123- protected function apply_prod_manifest_configuration ( $ manifest_path ) {
124- if ( file_exists ( $ manifest_path ) ) {
129+ protected function apply_prod_manifest_configuration () {
130+ if ( file_exists ( $ this -> manifest_path ) ) {
125131 $ this ->manifest_data = wp_json_file_decode (
126- $ manifest_path ,
132+ $ this -> manifest_path ,
127133 [ 'associative ' => true ]
128134 );
129135 } else {
0 commit comments