Laravel-Backpack / basset

Better asset helpers for Laravel apps.
MIT License
161 stars 10 forks source link

[WIP] Basset v2 Changes Shortlist #140

Open tabacitu opened 1 month ago

tabacitu commented 1 month ago

TODO:

--

ALSO TO DO:

DON'T DO:

--

LET'S NOT TALK ABOUT IT:

Examples:

@basset('http://example.com/select2.js')

{
  "select2.js" : "http://example.com/select2.js"
}

@basset('select2.js')
tabacitu commented 3 weeks ago

How everything would work - notes from conversation with @pxpm :

<?php

/** IN PRO COMPOSER PACKAGE */

// Step 1. Use the key in your blade file:
@basset('bp-datepicker-js')
@basset('bp-select2-js-'.$lang)
@basset('bp-bootstrap-js')
@basset('bp-slider-js', true, ['lazy' => true])
@basset('https://cdn.com/easymde.js')

// Step 2A. In ProServiceProvider:
Basset::map("bp-datepicker-js", "http://example.com/datepicker.js");
foreach ($languages as $lang) {
    Basset::map('bp-select2-js-'.$lang, "https://cdn.com/$lang/select2.js");
}

/** IN MAIN PROJECT (LARAVEL APP) */
/** TO OVERRIDE A KEY */

// Step 1. In a custom class Bassets specifies, do:
Basset::map("bp-datepicker-js", "http://example.com/datepicker.1.1.js");
foreach ($languages as $lang) {
    Basset::map('bp-select2-js-'.$lang, "https://cdn.com/$lang/select2.1.js");
}
Basset::map("bp-bootstrap-js", "http://bootstrap.com/smth.js", [
    'integrity' => "80eh1iud01hiefe10eij10fks10f",
])
Basset::map("bp-slider-js", "http://slider.com/script.js")
Basset::map("https://cdn.com/easymde.js", "https://npmjs.com/easymde/easymde.js")

// Step 2. Optionally, run:
php artisan basset:cache

---

# Behind the scenes:
# .basset.cache:
"bp-datepicker-js" => "Web/user/public/example.com/datepicker.1.1.js"
"bp-select2-en-js" => "Web/user/public/cdn.com/en/select.2.1.js"
"bp-select2-ro-js" => "Web/user/public/cdn.com/ro/select.2.1.js"
"bp-select2-fr-js" => "Web/user/public/cdn.com/fr/select.2.1.js"
"bp-select2-pt-js" => "Web/user/public/cdn.com/pt/select.2.1.js"
"bp-bootstrap-js" => "Web/user/public/bootstrap.com/smth.js"
"bp-slider-js" => "Web/user/public/slider.com/script.js"
"bp-slider-js" => "Web/user/public/slider.com/script.js"
"https://cdn.com/easymde.js" => "Web/user/public/npmjs.com/easymde/easymde.js"