diff --git a/Plugin.php b/Plugin.php
index 22cec54..b28b534 100644
--- a/Plugin.php
+++ b/Plugin.php
@@ -102,6 +102,7 @@ class Plugin extends PluginBase
],
'functions' => [
'manifest' => [TwigFilters::class, 'manifest'],
+ 'hmrAssets' => [TwigFilters::class, 'hmrAssets'],
],
];
}
diff --git a/classes/ManifestReader.php b/classes/ManifestReader.php
index 96c9ddc..4250802 100644
--- a/classes/ManifestReader.php
+++ b/classes/ManifestReader.php
@@ -1,8 +1,11 @@
manifest = json_decode(file_get_contents($manifestPath));
+ $this->manifest = collect(json_decode(file_get_contents($manifestPath)));
}
public function get(string $assetName)
{
- return $this->manifest->$assetName;
+ return $this->manifest->offsetGet($assetName);
+ }
+
+ public function toArray()
+ {
+ return $this->manifest;
}
}
diff --git a/classes/TwigFilters.php b/classes/TwigFilters.php
index acd8f72..8b6c369 100644
--- a/classes/TwigFilters.php
+++ b/classes/TwigFilters.php
@@ -12,4 +12,25 @@ class TwigFilters
return $manifest->getManifestReader()->get($assetName);
}
+
+ public static function hmrAssets()
+ {
+ if (\Config::get('app.debug')) {
+ $manifest = app()->get(Manifest::class);
+
+ assert($manifest instanceof Manifest);
+
+ $startsWithSubstring = 'vendors-node_modules';
+
+ foreach ($manifest->getManifestReader()->toArray() as $assetName => $assetsFullPath) {
+ if (starts_with($assetName, $startsWithSubstring)) {
+ if (ends_with($assetName, '.css')) {
+ echo '' . PHP_EOL;
+ } else {
+ echo '' . PHP_EOL;
+ }
+ }
+ }
+ }
+ }
}
diff --git a/components/Manifest.php b/components/Manifest.php
index 16b8ced..e7df347 100644
--- a/components/Manifest.php
+++ b/components/Manifest.php
@@ -1,6 +1,7 @@
'^[^/].*/manifest.json',
'validationMessage' => self::LANG_PREFIX . 'properties.path.validationMessage',
'placeholder' => 'assets/build/manifest.json',
+ 'default' => 'assets/build/manifest.json',
'showExternalParam' => false,
'required' => true,
]
@@ -49,7 +51,7 @@ class Manifest extends ComponentBase
*/
private function prepareVars(): void
{
- $this->manifestReader = new ManifestReader(base_path($this->property('path')));
+ $this->manifestReader = new ManifestReader(Theme::getActiveTheme()->getPath() . '/' . $this->property('path'));
}
public function getManifestReader(): ManifestReader