laravelpackage-development

laravel package development and link to css/js file


I am new in laravel package development and i want to link to css and js files in main view.

I do this, but it links to project path

<link rel="stylesheet" href="{{ public_path('css/style.css') }}">

but i want to link to css/js files in package directory.


Solution

  • You should publish the assets on the vendor first by running

    php artisan vendor:publish
    

    But, to do that, you also need to set the config on the package service provider

    public function boot()
    {
        $this->publishes([
            __DIR__.'/public' => public_path('vendor/bryanjack/dash'),
        ]);
    }
    

    And then your package will be published on the public directory