how to use an Asset of a package in Laravel without copying to the public folder

Asked

Viewed 106 times

0

I created a package Modular that is already working, However I am barred at the time of using assets. Not using the command

php artisan vendor:publish

I can’t get access to {{asset ('css/file.css')}} in my Barbershop. i wonder if there is any way to change the Asset path in my file Serviceprovider.php how can I indicate the path of the route file, the path of the Views folder, the translation path, or Migrations using the codes below:

$this->loadRoutesFrom(__DIR__.'/Routes/web.php');//Define o arquivo de rotas
$this->loadViewsFrom(__DIR__.'/Resources/views', 'NoMePaCoTe');//Define a pasta de uso ao usar return view('NoMePaCoTe:file') para exibir View
$this->loadMigrationsFrom(__DIR__.'/Database/migrations');//Pasta de migrations
$this->loadTranslationsFrom(__DIR__.'/Resources/lang', 'NoMePaCoTe');//Pasta de traduçoes

What do I do to do something like :

$this->loadAssetsFrom('/resources/assets/');//definir subpasta dentro do package como pasta de asset

and so be able to use the Assets in the Blade {{asset('css/file.css')}} or {{asset('NoMePaCoTe::css/file.css')}} Some solution to my problem ?

  • 1

    I believe it is not possible, since the only folder that the browser should access is the public for security reasons. But you can use webpack to generate the minified css file you have in Resource/Assets and copy to the public folder. In the documentation you can see this: Compiling Assets (Mix)

  • @Jedsonmelo, I have a multi-tenancy system. where each package, responds in a different domain. As I said, the Packages are already working and responding well to each one in one domain. what I want is nothing more than to force each package to use its own Asset without having to publish them. For me it is convenient not to compile, publish and compile for me already two works. the only thing I share among them is a Blade extrusion, a part of a navbar and a footer. everything else is different. understand? it makes no sense to publish everything in public folder.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.