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.

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

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') }}"/>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.