-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v2 - named assets, no more symlink, caching features #142
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
refs: #140
The basset refactor PR.
What's new? (Summary)
basset
disk, it points to the/public
folder instead of storage, removing the need for symlink.public/{basset_path}
to .gitignoreRemoving the symlink and adding .gitignore
This had been an issue for some of the users. The mangle between filesystem, permissions and symlinks had been a source of problems.
This PR removes the need for symlinking because the assets will be cached in the
/public
folder. Since the public folder is not.gitignored
by default, the install command now adds the basset folder to the gitignore.Cache URL's in dev mode
One painpoint of using basset in development was that you couldn't cache the http dependencies (usually cdns) and keep your "local" files "uncached", so that you could work developing your admin panel without internet access.
In this PR we introduce the
force_url_cache
, that will cache the urls even when you are in dev mode. That way it's possible to cache everything in advance withphp artisan basset:cache
, or at the required time when the asset is saw on the page for the first time.Local files (recaching issues)
While working locally, all local assets (eg,
vendor/backpack/crud/resources/assets/css/common.css
) were "re-cached" on every request. That was required to make the assets available "for public" usage (the vendor folder is not accessible).In this PR we introduced an "hash" that we store alongside the local files in the file map. That way, we only need to "re-cache", the ones were the content changed.
Named Assets
This is the block muscle of this PR. By using named assets we unlocked a lot of other possibilities.
The concept is simple, packages (like backpack/crud), register their named assets with
Basset::map()
, when refering to those packages, developers can use only@asset('asset-package-name')
.The advantages of this approach are:
Basset::map()
definition in 1 place, ensuring that no package conflicts occur by using multiple versions of the same package.All this now enables the workflow of publishing your assets to your repo, removing the need for calling
php artisan basset:cache
in production. Or by using a combination of both, and just calling:cache
without:clear
, so only the "changed" assets will be cached. If nothing changed, no assets are "re-cached".