I'm a little confused on the documentation for adding assets to my component, and getting an error message:
There is no "com_supersite.supersite" asset of a "script" type in the registry.
I have a media reference in my manifest file:
<media destination="com_supersite" folder="media">
<file>joomla.assets.json</file>
<folder>css</folder>
<folder>js</folder>
</media>
My joomla.assets.json file, which I think should register my assets:
{
"$schema": "https://developer.joomla.org/schemas/json-schema/web_assets.json",
"name": "com_supersite",
"version": "4.0.0",
"description": "Joomla CMS",
"license": "GPL-3.0-or-later",
"assets": [
{
"name": "com_supersite.supersite",
"type": "script",
"uri": "com_supersite/supersite.js",
"dependencies": [
"core"
],
"attributes": {
"defer": true
}
},
{
"name": "com_supersite.supersite",
"type": "style",
"uri": "com_supersite/supersite.css"
}
]
}
And then trying to use the script asset in my component view:
<?php
use Joomla\CMS\Factory;
\defined('_JEXEC') or die('Restricted access');
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->useScript('com_supersite.supersite');