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 files in resources/assets/javascripts , we must add gulp tasks to copy them. And this is the weakness of this method. And we need a path mapping in the browser debugger.

If we put these files in public/js , we will have our JS source and JS compiled in one place, and they will be corrupted.

So where should I store JS in Laravel 5?

+6
source share
1 answer

The answer of "Laravel-5" is to put them in resources/assets/javascripts . Then you use Laravel-Elixer, which is the new npm package from Taylor + Jeffrey Way, which handles all asset management for you using gulp.

Using Laravel-Elixer, you can publish, combine, modify and control all your css + js resources in a simple workflow.

Elixer does more - you can read about it here: https://github.com/laravel/elixir

Jeffrey Way also made an entire Laracast series (I think this series is free): https://laracasts.com/index/elixir

+10
source

Source: https://habr.com/ru/post/980491/


All Articles