Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should I store JS in Laravel 5?

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?

like image 318
Dmitry Avatar asked Jan 04 '15 12:01

Dmitry


1 Answers

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

like image 89
Laurence Avatar answered Oct 07 '22 17:10

Laurence