1

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.

alireza
  • 141
  • 1
  • 5

2 Answers2

3

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

bryanjack
  • 46
  • 4
0

asset() method is used to include CSS/JavaScript/images files, you can use it in your case https://laravel.com/docs/5.6/helpers#method-asset

<link rel="stylesheet" type="text/css" href="{{ asset('css/style.css') }}"/>
Jagjeet Singh
  • 1,564
  • 1
  • 10
  • 23