Laravel-Backpack / basset

Better asset helpers for Laravel apps.
MIT License
155 stars 11 forks source link

Does not save files included in css. #98

Closed dimkys closed 1 year ago

dimkys commented 1 year ago

@basset('https://cdn.jsdelivr.net/gh/RobiNN1/elFinder-Material-Theme/Material/css/theme.min.css')

The css file contains background: url(../images/loading.svg) src: url(../icons/material.eot?91804974); src: url(../icons/material.svg?91804974#material)

expected behavior: \storage\app\public\basset\cdn.jsdelivr.net\gh\RobiNN1\elFinder-Material-Theme\Material\css\theme.min.css \storage\app\public\basset\cdn.jsdelivr.net\gh\RobiNN1\elFinder-Material-Theme\Material\icons\material.eot?91804974 \storage\app\public\basset\cdn.jsdelivr.net\gh\RobiNN1\elFinder-Material-Theme\Material\icons\material.svg?91804974 \storage\app\public\basset\cdn.jsdelivr.net\gh\RobiNN1\elFinder-Material-Theme\Material\images\loading.svg

Actual result: \storage\app\public\basset\cdn.jsdelivr.net\gh\RobiNN1\elFinder-Material-Theme\Material\css\theme.min.css

But at the same time it tries to receive these files from storage. Did I miss some setting point or something else?

promatik commented 1 year ago

Hi @dimkys, that behaviour is expected, unfortunately we don't parse the css in order to get all the urls in it, and we don't plan to do it, mostly because the fix is quite simple;

Wherever you import that asset, you just need to import the dependencies without outputting them (bool $output is the second argument of the directive).

@basset('https://cdn.jsdelivr.net/gh/RobiNN1/elFinder-Material-Theme/Material/css/theme.min.css')
@basset('https://cdn.jsdelivr.net/gh/RobiNN1/elFinder-Material-Theme/Material/images/loading.svg', false)
@basset('https://cdn.jsdelivr.net/gh/RobiNN1/elFinder-Material-Theme/Material/icons/material.eot', false)
@basset('https://cdn.jsdelivr.net/gh/RobiNN1/elFinder-Material-Theme/Material/icons/material.svg', false)

This will cache those dependencies 👌 Let me know if it works or if you had any issues with it.

dimkys commented 1 year ago

Hi @promatik . The problem is that these dependencies are added by FileManager itself, i.e. this is not my code. And it doesn't work on its own, without corrections. But now it’s clear that this is a question for them. Thank you.

pxpm commented 1 year ago

Hello @dimkys

Thanks for the feedback.

I've identified the issue in FileManager and submitted a PR https://github.com/Laravel-Backpack/FileManager/pull/42 that fixes this.

Please do a composer update to get Backpack/FileManager 3.0.4. You will then need to php artisan vendor:publish --force --provider=Backpack\FileManager\FileManagerServiceProvider --tag=views NOTE: This will overwrite the elfinder views in resources/views/vendor/backpack/elfinder. If you have some customization there please go to the PR and manually add the changes without running this command.

It should give you something like: image

after that run the usual php artisan basset:clear && php artisan basset:cache so that the new files are cached too.

Let me know if you are still experiencing issues.

Cheers

dimkys commented 1 year ago

@pxpm Thank you, it works.