makeRelativeForJavaScript example

return $matches[0];
            }

            if ($this->supports($dependentAsset)) {
                // If we found the path and it's a JavaScript file, list it as a dependency.                 // This will cause the asset to be included in the importmap.                 $isLazy = str_contains($matches[0], 'import(');

                $asset->addDependency(new AssetDependency($dependentAsset$isLazy, false));

                $relativeImportPath = $this->createRelativePath($asset->publicPathWithoutDigest, $dependentAsset->publicPathWithoutDigest);
                $relativeImportPath = $this->makeRelativeForJavaScript($relativeImportPath);

                return str_replace($matches[1]$relativeImportPath$matches[0]);
            }

            return $matches[0];
        }$content);
    }

    public function supports(MappedAsset $asset): bool
    {
        return 'js' === $asset->publicExtension;
    }
Home | Imprint | This part of the site doesn't use cookies.