fahlisaputra / laravel-minify

Minify your blade views, html, css and obfuscate js files on the fly. Lightweight minifier for your Laravel project.
MIT License
70 stars 14 forks source link

CSS And JS is not working then including a middleware #10

Open kidsminnie opened 9 months ago

kidsminnie commented 9 months ago

I am facing a problem in this package, the problem is after minifying files the style is not implemented on any tag include file link, with this package javascript is also not working.

fahlisaputra commented 8 months ago

Can you show the code snippet to call the minify() function on the blade view?

And maybe you need to clear the cache, try running php artisan optimize

kidsminnie commented 8 months ago

` protected $middleware = [ // \App\Http\Middleware\TrustHosts::class, \App\Http\Middleware\TrustProxies::class, \Illuminate\Http\Middleware\HandleCors::class, \App\Http\Middleware\PreventRequestsDuringMaintenance::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,

   \Fahlisaputra\Minify\Middleware\MinifyCss::class,
    // Middleware to minify Javascript
    \Fahlisaputra\Minify\Middleware\MinifyJavascript::class,
    // Middleware to minify Blade
   \Fahlisaputra\Minify\Middleware\MinifyHtml::class,
];`

I am including middleware just like above. After this doing html is minified and js , css is also minified but the problem is JS is not working. I am using Alpine.js including in blade file as you mention in your code sinppet.

fahlisaputra commented 8 months ago

I'm sorry, Minify for Laravel has not been tested directly on several Javascript frameworks such as Alpine.js, Vue, etc. at this time.

As a first solution, you might be able to change the configuration in the auto insert semicolone section, please see the readme file to change the default value.

"insert_semicolon" => [
    'css' => env("MINIFY_CSS_SEMICOLON", true),
    'js' => env("MINIFY_JS_SEMICOLON", true),
],

after you changed the value, please run php artisan optimize

This feedback means a lot to me. Hope Minify for Laravel can be used in various frameworks in the future.