bnomei / kirby3-fingerprint

File Method and css/js helper to add hash to files
https://forum.getkirby.com/t/kirby-3-fingerprint-asset-cachebuster/23576
MIT License
37 stars 3 forks source link

Using `kirby()->root()` with manifest file in `fingerprint.query` option #24

Closed S1SYPHOS closed 3 years ago

S1SYPHOS commented 3 years ago

Hey there, I'd like to point query to my manifest file and then use Fingerprint::js on my my JS file. Unfortunately, that doesn't seem to work. The generated src attribute contains the path, but without the filename of my JS like assets/js/ instead of assets/js/main-somehash.js.

In my config.php, I'm doing this:

    'bnomei.fingerprint.query' => kirby()->root('assets') . '/manifest.json',

Inside Fingerprint.php, line 76, when dumping $this->option('query'), I'm getting the path to my kirby folder /assets/manifest.json instead of what I passed (see above).

??

// Edit: My manifest.json looks like this:

{
  "main.css": "main-8660347533.css",
  "main.js": "main-3883a30b2d.js",
  "main.min.css": "main-8f550e0370.min.css",
  "main.min.js": "main-83e06e8ea7.min.js"
}
S1SYPHOS commented 3 years ago

Yep, inside the hash() function the plugin, $query option('bnomei.fingerprint.query') equals /path/to/vendor/getkirby/assets/manifest.json, but I passed my own assets folder ..

// Edit: Passing the absolute path works, so it seems that kirby()->root('assets') gets corrupted in some way, maybe some kind of default / fallback? Gotta investigate ...

S1SYPHOS commented 3 years ago

This seems to be a general issue, so I asked the forum:

https://forum.getkirby.com/t/problem-with-kirby-being-passed-to-config-option/22754