1 min read

Laravel Bundle Assets

The past few weeks I have been building a few Laravel bundles and one of the features of bundles is the ability to have assets that are moved to your public folder during install. This is great when your bundle has css, js, images, etc..

The downside to this though is that while building the actual bundle it is a pain to keep having to run the following command each time you change a file:

php artisan bundle:publish

I have came up with a few different options to make this easier for developers. The first method which I believe would be supported across every os is to symlink the assets to public/bundles/folder/. However the down side to this is you have to add new symlinks when you add new files. So not ideal for the way I typically develop.

The second option is specific to mac but it works wonderfully. What I have done is purchase live reload and use it to run the bundle publish command. The reason I originally purchased the app was because I am using less for my css and I liked the fact that it would compile the css and also refresh your browser so you can see changes instantly.

The bigger benefit is live reload allows you to run terminal commands after you save and before it refreshes your browser. So all you have to do is add in your artisan command and not have to worry about it again. Here is a screenshot showing this:

livereload

Hopefully this will help you if you are building bundles with public assets. If you have any other tips please post them in the comments.