[4.2.0][Feature] Publish CSS & JS assets upon composer update #321
Replies: 16 comments
-
Hi @martijnb92 , I can confirm Indeed, we've removed it from the installation guide, because it had an unintended side-effect: every time you ran a I think a good solution for this would be to have a custom command instead of it, something like
This solution would:
Win-win, I think. What do you think about this plan @martijnb92 ? |
Beta Was this translation helpful? Give feedback.
-
Hello guys! I would go with with the artisan command also. But what other things will the
Why would the user wants to publish everything again ? Best, |
Beta Was this translation helpful? Give feedback.
-
@tabacitu That sound like a great idea. However, this might be a stupid question, isn't git perfect for this? If one asset is replaced with an identical asset, nothing should happen in git. I understand it's not very efficient to publish everything and let git sort out the differences but for me it worked fine this morning while updating, 110 modified assets, nowhere near 60+mb. Or am I missing something pretty obvious? Not very familiar with git..
|
Beta Was this translation helpful? Give feedback.
-
I'm sorry I haven't replied in a while @martijnb92 . This is still an issue I am not comfortable with, and that I'd like to to fix. You're right, Git is great at this. So most of the time people won't be getting a 60+ MB size bump, they'd get a smaller one. But:
I don't know why, but I'm still not really comfortable with instructing people to add I think more people need to see this, and pitch in. Something triggers my spidey-sense. Thoughts anyone? Should we publish assets again upon composer update? Feedback? @Laravel-Backpack/veterans ? PS. I would love to be able to symlink to our |
Beta Was this translation helpful? Give feedback.
-
Hmm... I've just tried to symlink again, using $target = base_path('vendor/backpack/crud/src/public/packages');
$link = public_path('packages');
symlink($target, $link); And... it works like a charm... I don't know what problems I had with this before, but... it looks like a very good solution... Of course, we'd still need to make some changes:
I don't know, But... it looks like we might finally have a working solution for this... Which would:
|
Beta Was this translation helpful? Give feedback.
-
I would go for option A, since the packages folder might be in use. Creating a symlink for each dependency looks messy to me. Interesting discussion over here #1404 |
Beta Was this translation helpful? Give feedback.
-
the "laravel way" for assets would be doing the same thing as https://laravel.com/docs/7.x/frontend
and backpack using the output from laravel mix, let's say...
using let's say the command adds something like this to
|
Beta Was this translation helpful? Give feedback.
-
@eduardoarandah this mean, we need installed node.js right? |
Beta Was this translation helpful? Give feedback.
-
Node? Not at all. This is the recommended way to do it. |
Beta Was this translation helpful? Give feedback.
-
This does reaffirm his point, if it’s a small project that can’t have node on the server, then it’s even less likely there’s a CI/CD in the mix which handles deployments which most likely will cost the dev money to do |
Beta Was this translation helpful? Give feedback.
-
@OwenMelbz Laravel is a framework, not a CMS, it’s expected to be built locally and then uploaded to the server. CICD is an option. Node is not supposed to be used in the server. Using node to build in production server is a terrible idea btw, you may consume a lot of memory and trigger the oom killer. Building locally also opens the possibility of customization via sass variables. (Think of a dark theme) |
Beta Was this translation helpful? Give feedback.
-
I’m not disputing that. I’m referring to how @lotarbo was saying requiring node can complicate certain projects, and how the response of “use a CI” to solve it, isn’t a solution everybody around the world has the luxury to do. If anything should go down a similar route to Nova with providing a prebuilt published version. Then if people want to delete the prebuilt one and run their own build pipeline they have the choice. There’s a balance that should be made between encouraging a good developer experience, making the tool and project as accessible as possible for everybody. And then “doing it the right way” Laravel and Rails are built on a mantra of providing solid tools with a good developer experience. Otherwise we’d all be working with complex code bases like Magento. Empathy for those less fortunate goes along way, so considering how those will work with the tool is important to prevent any sense of elitism or tribalism and alienating others |
Beta Was this translation helpful? Give feedback.
-
I don't find recommending to use Node.js unreasonable at all. I think that Laravel Mix is a really good fit for this use case and Laravel does come with a package.json file included by default. (BTW, Nova also has an expectation for Node.js) FYI, Rails does make it a little easier to add a 3rd party package (gem) to your project without having to "publish" its assets and pollute your own codebase. But that's only because it comes with a pre-packaged asset pipeline (Sprockets), which does pretty much what Laravel Mix does by default (e.g. asset compilation). In Laravel, there seems to be a lack of a standard asset pipeline, but I'd say that Mix is getting pretty close. My 2c: it would be nice if Backpack worked similar to how the other 'standard' Laravel front-end dependencies (e.g. Bootstrap, Vue) are set up:
For projects not using Laravel Mix, perhaps it would make sense to publish the assets onto a CDN or make them readily available for including in the public/ directory. |
Beta Was this translation helpful? Give feedback.
-
That's the thing... I kind of agree with ALL of you 😄 Yes like @eduardoarandah & @eronisko mentioned, using NPM and Laravel Mix is the "standard way" of doing things - and it would be easy to adopt it - Backpack already uses Laravel Mix under the hood, it has a mix file and a package.json file. But, like @OwenMelbz said, we should also take into account that not everybody want or knows how to install and use NPM. One thing I've always tried to keep in Backpack is a very simple stack - I think that greatly improves the developer experience. KISS. And though there's a super-simple analogy between composer and NPM, imho one is great and the other sucks 😆 Add asset compilation and minification to the mix (pun intended) and you've got yourself a whole new thing you need to learn and understand, before you use Backpack. That's why it's a tough nut to crack 😄 This is something I've wanted to take a stab at for quite a while now. And now that 4.1 is out the door, we can finally do this for the 4.2 release. Here's what I currently think about this, what we can do right now, in 4.1, as non-breaking changes:
But a more forward-looking solution, inside 4.2:
I'm eager to see what you think about #313 , and if I've correctly identified the problems - or misunderstood somehow. Cheers! |
Beta Was this translation helpful? Give feedback.
-
What about creating a separate ready to use package which includes all dependencies / builds for those who want it, which can be included via composer |
Beta Was this translation helpful? Give feedback.
-
I will close this discussion since we have now basset to handle assets on Backpack. Cheers. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug report
What I did
Upgrading Backpack to 4.0.18 for the updated packages
composer update
What I expected to happen
By upgrading Backpack I expect the new packages to be copied to the public folder
What happened
No updated packages are copied
What I've already tried to fix it
Previously in the upgrade guide v3 to v4 there was a post-update command for the composer.json file
This command is now removed, so I also updated my composer file to reflect these changes.
Why has this been done?
After each update I manually run:
php artisan vendor:publish --provider="Backpack\CRUD\BackpackServiceProvider" --tag=public --force
This copies the updated packages. Am I missing something or is this auto update command removed on purpose?
Backpack, Laravel, PHP, DB version
Backpack 4.0.18
Laravel 6.5.1
PHP 7.3.8
Beta Was this translation helpful? Give feedback.
All reactions