Open tomkiss opened 4 days ago
Hi @tomkiss,
You should be able to write a short custom closure-based strategy in your config file to support Vite's manifest format.
Here's an example:
<?php
use club\assetrev\exceptions\ContinueException;
return [
'pipeline' => 'vite|querystring|passthrough',
'strategies' => [
'vite' => function ($filename, $config) {
$manifest = json_decode(file_get_contents($config['manifestPath']), true);
return $manifest[$filename]['file'] ?? throw new ContinueException("Asset `$filename` not found in manifest file");
},
'querystring' => \club\assetrev\utilities\strategies\QueryStringStrategy::class,
'passthrough' => function ($filename, $config) {
return $filename;
},
],
'manifestPath' => '@webroot/mix-manifest.json',
'assetsBasePath' => '@webroot',
'assetUrlPrefix' => '@web',
];
Let me know if that helps at all!
Thanks, that's super helpful!
When using Vite to generate a manifest, the format is slightly different, e.g:
This results in an error when using Asset Rev
...because it expects a string.
Could the getAssetFilename function be updated to be less restrictive?