Laravel-modules: How to include modules assets

Created on 2 Mar 2017  路  12Comments  路  Source: nWidart/laravel-modules

I have a .js file in my Modules\ModuleName\Assets folder. I want to use it in other module's views files. How i can to include it in html.

Most helpful comment

Run php artisan module:publish.

All 12 comments

Like so:

{{ Module::asset('blog:js/script.js') }}

This assumes your script is located at /Modules/ModuleName/Assets/js/script.js. If it is not in a folder, just omit the js/ part in the asset call.

(Found here.)

Using the Module::asset('blog:js/script.js') function just gives me a 404 error when attempting to link to the files. I'm running this on artisan serve.

Did you publish your module assets ? (command in the docs as well)

oh, thx a lot)

Hi, how can we handle assets files ?
In fact I use Bower and would like to copy all assets from the bower_components directory instead of Assets directory.
Modules/OwlCarousel2
---bower.json
---Assets
---bower_components

It's more simple I think to update only the bower.json and call the publish command

Thanks for your help

Please help me to publish module assets?

I tried Module::asset('blog:js/script.js') function just gives me a 404 error.

Thanks.

Run php artisan module:publish.

Hi nWidart,

Thank you for your help. I run the publish command, it says published but still it is not working.

My full line of code is:

File is inside Modules/Lab/Assets/css/style.css

Thanks

Thanks @nWidart for your quick while, I tried again and looks good now.

prayas daai malai css ra js , image haru Module ko vitra raakhnu pareko kasari solve garnu vayo

Thanks @nWidart for your quick while, I tried again and looks good now.

how can you solved it please help me

@nWidart please can you tell me command to publish assets

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KyawNaingTun picture KyawNaingTun  路  16Comments

githubmarau picture githubmarau  路  29Comments

bashet picture bashet  路  19Comments

esipavicius picture esipavicius  路  13Comments

ridwanskaterock picture ridwanskaterock  路  12Comments