Closed cbergen closed 1 year ago
I found a solution using the package: https://github.com/idleberg/php-vite-manifest
use Idleberg\ViteManifest\ViteManifest;;
$baseUrl = get_stylesheet_directory_uri() . '/dist/';
$manifest = get_stylesheet_directory() . "/dist/manifest.json";
$vm = new ViteManifest($manifest, $baseUrl);
/*
Rich text editor style
*/
add_action('admin_init', function () use ($vm) {
foreach ($vm->getStyles("src/editor.js") as $style) {
add_editor_style($style['url']);
}
});
It would be handy to have a way to get at the URLs for any specific asset instead of just inserting into the head or returning the html tag.
If there were a function
getStyleUrls()
I would use this like so:This would also give me the flexibility to use
wp_enqueue()
as normal.If there's another way to achieve the same thing, please let me know!