diff --git a/app/Providers/FinderProvider.php b/app/Providers/FinderProvider.php index 5397e95..a99d4a4 100644 --- a/app/Providers/FinderProvider.php +++ b/app/Providers/FinderProvider.php @@ -15,7 +15,7 @@ class FinderProvider { /** @const Application paths to be hidden */ protected const APP_FILES = [ - 'app', 'node_modules', 'vendor', 'mix-manifest.json', 'index.php' + 'app', 'node_modules', 'vendor', 'index.php' ]; /** @const Array of sort options mapped to their respective methods */ diff --git a/app/ViewFunctions/Asset.php b/app/ViewFunctions/Asset.php index 29444d9..d97afc9 100644 --- a/app/ViewFunctions/Asset.php +++ b/app/ViewFunctions/Asset.php @@ -2,8 +2,6 @@ namespace App\ViewFunctions; -use Tightenco\Collect\Support\Collection; - class Asset extends ViewFunction { /** @const Constant description */ @@ -21,30 +19,8 @@ class Asset extends ViewFunction */ public function __invoke(string $path): string { - $assetPath = self::ASSET_PATH . $path; + $assetPath = dirname($_SERVER['SCRIPT_NAME']) . self::ASSET_PATH . ltrim($path, '/'); - if ($this->mixManifest()->has($assetPath)) { - return $this->mixManifest()->get($assetPath); - } - - return $assetPath; - } - - /** - * Return the mix manifest collection. - * - * @return \Tightenco\Collect\Support\Collection - */ - protected function mixManifest(): Collection - { - $mixManifest = $this->container->get('base_path') . '/mix-manifest.json'; - - if (! is_file($mixManifest)) { - return new Collection(); - } - - return Collection::make( - json_decode(file_get_contents($mixManifest), true) ?? [] - ); + return '/' . ltrim($assetPath, '/'); } } diff --git a/artifact.files b/artifact.files index 0ff55bd..4622abb 100644 --- a/artifact.files +++ b/artifact.files @@ -4,6 +4,5 @@ vendor .env.example directory-lister.svg LICENSE -mix-manifest.json README.md index.php diff --git a/artifacts.include b/artifacts.include index 65f50bd..6fed5fc 100644 --- a/artifacts.include +++ b/artifacts.include @@ -5,6 +5,5 @@ vendor .htaccess directory-lister.svg LICENSE -mix-manifest.json README.md index.php diff --git a/tests/TestCase.php b/tests/TestCase.php index 92ae6a9..ea87950 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -24,6 +24,8 @@ class TestCase extends PHPUnitTestCase */ public function setUp(): void { + $_SERVER['SCRIPT_NAME'] = '/index.php'; + $this->config = new Config([ 'app' => [ 'sort_order' => 'type', diff --git a/tests/ViewFunctions/AssetTest.php b/tests/ViewFunctions/AssetTest.php index 542cb44..0d66644 100644 --- a/tests/ViewFunctions/AssetTest.php +++ b/tests/ViewFunctions/AssetTest.php @@ -11,19 +11,7 @@ class AssetTest extends TestCase { $asset = new Asset($this->container, $this->config); - $this->assertEquals('/app/dist/test.css', $asset('test.css')); - $this->assertEquals( - '/app/dist/app.css?id=417c7a9bc03852aafb27', - $asset('app.css') - ); - } - - public function test_it_can_return_an_asset_path_without_a_mix_manifest(): void - { - $this->container->set('base_path', $this->filePath('subdir')); - $asset = new Asset($this->container, $this->config); - - $this->assertEquals('/app/dist/test.css', $asset('test.css')); - $this->assertEquals('/app/dist/app.css', $asset('app.css')); + $this->assertEquals('/app/dist/css/app.css', $asset('css/app.css')); + $this->assertEquals('/app/dist/js/app.js', $asset('js/app.js')); } } diff --git a/tests/_files/mix-manifest.json b/tests/_files/mix-manifest.json deleted file mode 100644 index 21db9e4..0000000 --- a/tests/_files/mix-manifest.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "/app/dist/app.js": "/app/dist/app.js?id=6753a7269276c7b52692", - "/app/dist/app.css": "/app/dist/app.css?id=417c7a9bc03852aafb27" -}