Hi guys!
I have a problem. I need a help.
I want to link to the css or js file inside the module.
When I try to run the command
{{Module :: asset ('blog: css / blog.css')}} in the module's app.blade.php file.
is on the head tag but it does not work.
I have public module as follows
php artisan module: publish
But everything is not better.
Here is my directory structure:
-Blog
-Assets
-css
blog.css
-Providers
BlogServiceProvider.php
-Resource
-views
app.blade.php
Do I need to configure anything in BlogServiceProvider.php file?
Thanks for all the help.
I wish you a happy day
you can use Laravel Mix to copy blog.css to the public folder and use mix('css/blog.css')
// Modules/Blog/webpack.mix.js
const { mix } = require('laravel-mix');
mix.setPublicPath('../../public');
mix.copy( __dirname + '/Assets/blog.css', 'css/blog.css');
or using php
<style>
{!! file_get_contents(Module::find('blog')->getPath() . '/Assets/blog.css'); !!}
</style>
Your first step is good
I have followed it and now it is separated from main laravel source.
In the module's view file I just need to
<link rel = "stylesheet" href = "{{asset ('modules / blog / css / blog.css')}}">
and in the webpack.mix.js
mix.copyDirectory (__dirname + '/ Assets', '../../public/modules/blog');
Everything is much clearer now.
thank you @KABBOUCHI
@dang-tien if your issue has been resolved, plz close it :)
Most helpful comment
Your first step is good
I have followed it and now it is separated from main laravel source.
In the module's view file I just need to
<link rel = "stylesheet" href = "{{asset ('modules / blog / css / blog.css')}}">and in the webpack.mix.js
mix.copyDirectory (__dirname + '/ Assets', '../../public/modules/blog');Everything is much clearer now.
thank you @KABBOUCHI