There are 2 places where I can store javascripts: resources/assets/javascripts
and public/js
.
If we put the files in resources/assets/javascripts
, we should add gulp tasks to copy them. And this is a weakness of this method. And we will need path mapping in browser debugger.
If we put these files in public/js
, we will have our source JS and compiled JS in one place and they will be messed up.
So, where should I store JS in Laravel 5?
The "Laravel-5" answer is to put them in resources/assets/javascripts
. Then you use Laravel-Elixer, which is the new npm
package from Taylor + Jeffrey Way that handles the entire asset management for you using gulp.
Using Laravel-Elixer, you can publish, combine, minifiy and version control all your css + js assets in a simple workflow.
Elixer does alot more - you can read about it here: https://github.com/laravel/elixir
Jeffrey Way has also done a whole Laracast series on it (which I think this series is free): https://laracasts.com/index/elixir
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With