Neeraj Verma
Neeraj Verma

Reputation: 2294

laravel accesing resource folder by helper method+ routing

Edit : Solved ,as DigitalDrifter siggested , npm run dev will automatically move all assets deom resouece to public . so dont waste time on resource folder access .

as per laravel docs ,I run command

php artisan ui vue --auth

to create auth scaffoldings . it created all assests in resource folder project I want to access js /css inside resource folder by helper method+ routing

enter image description here

app.blade.php

<script src="{{ asset('js/app.js') }}" defer></script>
<link href="{{ asset('css/app.css') }}" rel="stylesheet">

here is what i tried in routing to access js or scss file

Route::get('/resources/js/{filename}', function($filename){
    $path = resource_path() . '\js\{filename}';

    $file = File::get($path);
    $type = File::mimeType($path);

    $response = Response::make($file, 200);
    return $response;
});

Route::get('/resources/css/{scss}', function($filename){
    $path = resource_path() . '\sass\{scss}';

    $file = File::get($path);
    $type = File::mimeType($path);

    $response = Response::make($file, 200);
    return $response;
});

but it is not working .any thing more can be tried to access resource ??

Upvotes: 0

Views: 397

Answers (0)

Related Questions