mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
33 lines
1.0 KiB
PHP
33 lines
1.0 KiB
PHP
<?php
|
|
|
|
use Illuminate\Support\Str;
|
|
use Illuminate\Support\HtmlString;
|
|
|
|
/** @var $container \Illuminate\Container\Container */
|
|
/** @var $jigsaw \TightenCo\Jigsaw\Jigsaw */
|
|
|
|
function mix($path, $manifestDirectory = '')
|
|
{
|
|
static $manifests = [];
|
|
if (! Str::startsWith($path, '/')) {
|
|
$path = "/{$path}";
|
|
}
|
|
if ($manifestDirectory && ! Str::startsWith($manifestDirectory, '/')) {
|
|
$manifestDirectory = "/{$manifestDirectory}";
|
|
}
|
|
|
|
$manifestPath = public_path($manifestDirectory.'/mix-manifest.json');
|
|
|
|
if (! isset($manifests[$manifestPath])) {
|
|
if (! file_exists($manifestPath)) {
|
|
throw new Exception('The Mix manifest does not exist.');
|
|
}
|
|
$manifests[$manifestPath] = json_decode(file_get_contents($manifestPath), true);
|
|
}
|
|
$manifest = $manifests[$manifestPath];
|
|
if (! isset($manifest[$path])) {
|
|
throw new InvalidArgumentException("Unable to locate Mix file: {$path}.");
|
|
}
|
|
return new HtmlString($manifestDirectory.$manifest[$path]);
|
|
}
|